TelecomNumber.spec.js
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
define(function(require) {
'use strict';
var TelecomNumber = require('ofbiz/model/TelecomNumber');
var _ = require('underscore');
var Backbone = require('backbone');
require('backbone-validation');
describe('TelecomNumber', function() {
it('exists', function() {
expect(TelecomNumber).toBeTruthy();
});
});
describe('TelecomNumber', function() {
beforeEach(function() {
_.extend(Backbone.Model.prototype, Backbone.Validation.mixin);
});
it('validation', function() {
var result, telecomNumber;
telecomNumber = new TelecomNumber();
expect(telecomNumber.validate()).toBeUndefined();
expect(telecomNumber.isValid()).toBe(true);
telecomNumber._isRequired = true;
// changing _isRequired doesn't have an effect until validate is called
expect(telecomNumber.isValid()).toBe(true);
result = telecomNumber.validate()
expect(result).not.toBeUndefined();
expect(telecomNumber.isValid()).toBe(false);
expect(_.keys(result).sort()).toEqual(['contactNumber']);
expect(result['contactNumber']).toEqual(jasmine.any(String));
telecomNumber.set('contactNumber', '123-456-7890');
result = telecomNumber.validate()
expect(result).toBeUndefined();
expect(telecomNumber.isValid()).toBe(true);
telecomNumber._isRequired = false;
expect(telecomNumber.isValid()).toBe(true);
expect(telecomNumber.validate()).toBeUndefined();
expect(telecomNumber.isValid()).toBe(true);
});
});
});