1 | var Compound = require('../').Compound;
|
2 | var should = require('should');
|
3 |
|
4 | describe('Compound', function() {
|
5 |
|
6 | it('could be created with no app', function() {
|
7 | (function() {
|
8 | new Compound;
|
9 | }).should.not.throw;
|
10 | });
|
11 |
|
12 | it('should have ability to run tools when instantiated with no app', function () {
|
13 | var c = new Compound;
|
14 | c.generators.init(c);
|
15 | c.generators.list().should.equal('app');
|
16 | });
|
17 |
|
18 | it('should allow to find model by name', function() {
|
19 | var c = new Compound;
|
20 | c.models = {Model: function Model() {}, ModelTwo: true};
|
21 | should.exist(c.model('Model'));
|
22 | should.exist(c.model('model'));
|
23 | should.not.exist(c.model('model', true));
|
24 | should.exist(c.model('ModelTwo'), true);
|
25 |
|
26 |
|
27 | should.not.exist(c.model('ModelThree'));
|
28 | c.model(function ModelThree(){});
|
29 | should.exist(c.model('ModelThree'));
|
30 |
|
31 |
|
32 | var model = function(){};
|
33 | model.modelName = 'HelloJuggling';
|
34 | c.model(model);
|
35 | should.exist(c.model('HelloJuggling'));
|
36 |
|
37 |
|
38 | (function() {
|
39 | c.model(function() {});
|
40 | }).should.throw('Named function or jugglingdb model required');
|
41 | });
|
42 |
|
43 | describe('run initializers', function(){
|
44 | var app, c, root, path = '/test';
|
45 |
|
46 | before(function(done) {
|
47 | app = getApp();
|
48 | c = app.compound;
|
49 | c.on('ready', function() {
|
50 | root = c.root + path;
|
51 | done();
|
52 | });
|
53 | });
|
54 |
|
55 | it('should fail to initialize files with README files', function() {
|
56 | (function(){
|
57 | c.runInitializers(root);
|
58 | }).should.throw();
|
59 | });
|
60 |
|
61 | it('should initialize files without README with config pattern', function() {
|
62 | app.set('ignore initializers pattern', /^\.|\.md$/);
|
63 | (function(){
|
64 | c.runInitializers(root);
|
65 | }).should.not.throw();
|
66 | });
|
67 |
|
68 | });
|
69 |
|
70 | });
|