Sha256: 28d93aad9d6b0b7efe6498d1e6979158e3fb9471582b5a7df1b09f5fe0d50a90

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

describe 'uki.data.Model'

    before_each
        model = new uki.data.Model();
    end
    
    it 'should allow event binding'
        uki.isFunction(model.bind).should.be_true
    end
    
    it 'should update model'
        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.update({ name: 'something' });
    end
    
    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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
uki-1.1.4 frameworks/uki/spec/unit/data/model.spec.js
uki-1.1.3 frameworks/uki/spec/unit/data/model.spec.js
uki-1.1.2 frameworks/uki/spec/unit/data/model.spec.js
uki-1.1.1 frameworks/uki/spec/unit/data/model.spec.js
uki-1.1.0 frameworks/uki/spec/unit/data/model.spec.js
uki-1.0.2 frameworks/uki/spec/unit/data/model.spec.js