Base.spec.js 1.02 KB
define(function(require) {
    'use strict';

    var Base = require('ofbiz/model/Base');
    var Backbone = require('backbone');

    describe('Base', function() {
        it('exists', function() {
            expect(Base).toBeTruthy();
        });
    });
    describe('Base', function() {
        it('_createRequiredValidator', function() {
            var TestModel = Backbone.Model.extend({
                required: function() {
                    return this.validators.all[0].required.call(this, arguments);
                },
                validators: {
                    all: [
                        Base.createRequiredValidator('jasmine test'),
                    ],
                },
            });
            var testModel = new TestModel();
            expect(testModel.required()).toBe(undefined);
            testModel._isRequired = false;
            expect(testModel.required()).toBe(false);
            testModel._isRequired = true;
            expect(testModel.required()).toBe(true);
        });
    });
});