frameworks/uki/spec/unit/data/model.spec.js in uki-1.0.1 vs frameworks/uki/spec/unit/data/model.spec.js in uki-1.0.2
- old
+ new
@@ -7,23 +7,34 @@
it 'should allow event binding'
uki.isFunction(model.bind).should.be_true
end
it 'should update model'
- model.change({ firstName: 'John', lastName: 'Smith' })
+ model.update({ firstName: 'John', lastName: 'Smith' })
model.firstName.should.be 'John'
model.lastName.should.be 'Smith'
end
it 'should notify of changed fields'
model.bind('change', function(e) {
e.fields.should.eql ['name']
e.changes.name.should.not.be_null
});
- model.change({ name: 'something' });
+ model.update({ name: 'something' });
end
- it 'should use 2 params call'
- model.change('name', 'John Smith')
- model.name.should.be 'John Smith'
+ it 'should allow accesor methods'
+ uki.data.model.addFields(model, ['firstName', 'lastName'])
+ model.update({ firstName: 'John', lastName: 'Smith' })
+ model.firstName().should.be 'John'
+ model.lastName().should.be 'Smith'
+ end
+
+ it 'should trigger change with accessor methods'
+ uki.data.model.addFields(model, ['firstName', 'lastName'])
+ model.bind('change', function(e) {
+ e.fields.should.eql ['firstName']
+ e.changes.firstName.should.be_true
+ });
+ model.firstName('something')
end
end
\ No newline at end of file