forked from yeoman/generator-backbone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-coffee.js
121 lines (106 loc) · 3.14 KB
/
test-coffee.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*global describe:true, beforeEach:true, it:true */
'use strict';
var path = require('path');
var yeoman = require('yeoman-generator');
var helpers = yeoman.test;
var assert = yeoman.assert;
var fs = require('fs');
var test = require('./helper.js');
describe('Backbone generator test with --coffee option', function () {
beforeEach(function (done) {
helpers.testDirectory(path.join(__dirname, './temp'), function (err) {
if (err) {
return done(err);
}
this.backbone = {};
this.backbone.app = test.createAppGenerator();
helpers.mockPrompt(this.backbone.app, {
features: ['compassBootstrap', 'coffee']
});
var out = [
'{',
' "generator-backbone": {',
' "appPath": "app",',
' "appName": "Temp"',
' }',
'}'
];
fs.writeFileSync('.yo-rc.json', out.join('\n'));
done();
}.bind(this));
});
it('creates expected files', function (done) {
var expectedContent = [
['bower.json', /"name": "temp"/],
['package.json', /"name": "temp"/]
];
var expected = [
'Gruntfile.js',
'app/404.html',
'app/favicon.ico',
'app/robots.txt',
'app/index.html',
'.gitignore',
'.gitattributes',
'.bowerrc',
'.jshintrc',
'.editorconfig',
'.yo-rc.json',
'app/scripts/main.coffee'
];
this.backbone.app.run([], function () {
assert.file(expected);
assert.fileContent(expectedContent);
done();
});
});
describe('creates model in coffeescript', function () {
it('without failure', function (done) {
this.backbone.app.run([], function () {
test.createSubGenerator('model', function () {
assert.fileContent(
'app/scripts/models/foo.coffee', /class Temp.Models.Foo extends Backbone.Model/
);
done();
});
});
});
});
describe('creates collection in coffeescript', function () {
it('without failure', function (done) {
this.backbone.app.run({}, function () {
test.createSubGenerator('collection', function () {
assert.fileContent(
'app/scripts/collections/foo.coffee', /class Temp.Collections.Foo extends Backbone.Collection/
);
done();
});
});
});
});
describe('creates router in coffeescript', function () {
it('without failure', function (done) {
this.backbone.app.run({}, function () {
test.createSubGenerator('router', function () {
assert.fileContent(
'app/scripts/routes/foo.coffee', /class Temp.Routers.Foo extends Backbone.Router/
);
done();
});
});
});
});
describe('creates view in coffeescript', function () {
it('without failure', function (done) {
this.backbone.app.run({}, function () {
test.createSubGenerator('view', function () {
assert.fileContent(
'app/scripts/views/foo.coffee', /class Temp.Views.Foo extends Backbone.View/
);
assert.file('app/scripts/templates/foo.ejs');
done();
});
});
});
});
});