Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions test/mixins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ mixins.define('TimeStamp', timestamps);

describe('Model class', function () {

it('should define a mixin', function() {
it('should define mixins', function() {
mixins.define('Example', function(Model, options) {
Model.prototype.example = function() {
return options;
};
});
mixins.define('Demo', function(Model, options) {
Model.demoMixin = options.ok;
});
});

it('should apply a mixin class', function() {
Expand All @@ -58,7 +61,7 @@ describe('Model class', function () {

var memory = new DataSource('mem', {connector: Memory}, modelBuilder);
var Item = memory.createModel('Item', { name: 'string' }, {
mixins: { TimeStamp: true, demo: true, Address: true }
mixins: { Address: true }
});

var properties = Item.definition.properties;
Expand All @@ -70,11 +73,12 @@ describe('Model class', function () {
it('should apply mixins', function(done) {
var memory = new DataSource('mem', {connector: Memory}, modelBuilder);
var Item = memory.createModel('Item', { name: 'string' }, {
mixins: { TimeStamp: true, demo: { ok: true } }
mixins: { TimeStamp: true, Demo: { ok: true } }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Demo: { value: true } would make the intention more clear. L52 will become easier to understand too:

Model.demoMixin = options.value

});

Item.mixin('Example', { foo: 'bar' });
Item.mixin('other');

Item.demoMixin.should.be.true;

var properties = Item.definition.properties;
properties.createdAt.should.eql({ type: Date });
Expand Down