Cleanup mixin tests
This commit is contained in:
parent
f671c9c726
commit
d1466bffcb
|
@ -42,12 +42,15 @@ mixins.define('TimeStamp', timestamps);
|
||||||
|
|
||||||
describe('Model class', function () {
|
describe('Model class', function () {
|
||||||
|
|
||||||
it('should define a mixin', function() {
|
it('should define mixins', function() {
|
||||||
mixins.define('Example', function(Model, options) {
|
mixins.define('Example', function(Model, options) {
|
||||||
Model.prototype.example = function() {
|
Model.prototype.example = function() {
|
||||||
return options;
|
return options;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
mixins.define('Demo', function(Model, options) {
|
||||||
|
Model.demoMixin = options.ok;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should apply a mixin class', function() {
|
it('should apply a mixin class', function() {
|
||||||
|
@ -58,7 +61,7 @@ describe('Model class', function () {
|
||||||
|
|
||||||
var memory = new DataSource('mem', {connector: Memory}, modelBuilder);
|
var memory = new DataSource('mem', {connector: Memory}, modelBuilder);
|
||||||
var Item = memory.createModel('Item', { name: 'string' }, {
|
var Item = memory.createModel('Item', { name: 'string' }, {
|
||||||
mixins: { TimeStamp: true, demo: true, Address: true }
|
mixins: { Address: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
var properties = Item.definition.properties;
|
var properties = Item.definition.properties;
|
||||||
|
@ -70,11 +73,12 @@ describe('Model class', function () {
|
||||||
it('should apply mixins', function(done) {
|
it('should apply mixins', function(done) {
|
||||||
var memory = new DataSource('mem', {connector: Memory}, modelBuilder);
|
var memory = new DataSource('mem', {connector: Memory}, modelBuilder);
|
||||||
var Item = memory.createModel('Item', { name: 'string' }, {
|
var Item = memory.createModel('Item', { name: 'string' }, {
|
||||||
mixins: { TimeStamp: true, demo: { ok: true } }
|
mixins: { TimeStamp: true, Demo: { ok: true } }
|
||||||
});
|
});
|
||||||
|
|
||||||
Item.mixin('Example', { foo: 'bar' });
|
Item.mixin('Example', { foo: 'bar' });
|
||||||
Item.mixin('other');
|
|
||||||
|
Item.demoMixin.should.be.true;
|
||||||
|
|
||||||
var properties = Item.definition.properties;
|
var properties = Item.definition.properties;
|
||||||
properties.createdAt.should.eql({ type: Date });
|
properties.createdAt.should.eql({ type: Date });
|
||||||
|
|
Loading…
Reference in New Issue