lore
Version:
Convention-driven framework for building React-Redux applications
75 lines (61 loc) • 1.6 kB
JavaScript
var expect = require('chai').expect;
var Lore = require('../../src/app/index');
var loaderHelper = require('../helpers/loaderHelper');
var config = {
hooks: require('../defaultHooks')
};
describe('lore#models', function() {
var lore = null;
beforeEach(function() {
lore = new Lore();
});
describe('when models exist', function() {
beforeEach(function() {
loaderHelper.stub({
models: {
todo: {},
list: {}
}
});
});
it("should instantiate them and attach to lore.models", function() {
lore.build(config);
expect(lore.models).to.include.keys([
'todo',
'list'
]);
expect(lore.models.todo).to.be.a('function');
});
});
describe('when models/config and models/todo both exist', function() {
beforeEach(function() {
loaderHelper.stub({
});
loaderHelper.stub({
config: {
models: {
apiRoot: 'https://config.models',
properties: {
propA: 'a'
}
}
},
models: {
todo: {
pluralize: false,
properties: {
propB: 'b'
}
}
}
});
});
it("the final properties should be a combination of the two configurations", function() {
lore.build(config);
var prototype = lore.models.todo.prototype;
expect(prototype.urlRoot).to.equal('https://config.models/todo');
expect(prototype.propA).to.equal('a');
expect(prototype.propB).to.equal('b');
});
});
});