forked from yeoman/generator-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute.js
65 lines (59 loc) · 1.7 KB
/
route.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
'use strict';
var path = require('path');
var helpers = require('yeoman-test');
var assert = require('yeoman-assert');
var generateFullProject = require('./utils').generateFullProject;
describe('angular:route', function () {
beforeEach(function (done) {
generateFullProject()
.withPrompts({
modules: ['routeModule']
})
.on('end', function () {
this.angularRoute = helpers.run(require.resolve('../route'))
.withGenerators([
require.resolve('../controller'),
require.resolve('../view')
])
.withOptions({
appPath: 'app'
})
.withArguments(['simpleroute']);
// Hack to not clear the directory
this.angularRoute.inDirSet = true;
done();
}.bind(this));
});
it('generates default route items', function (done) {
this.angularRoute.on('end', function () {
assert.file([
'app/scripts/controllers/simpleroute.js',
'test/spec/controllers/simpleroute.js',
'app/views/simpleroute.html'
]);
assert.fileContent(
'app/scripts/app.js',
/when\('\/simpleroute'/
);
done();
});
});
it('generates route items with the route uri given', function (done) {
this.angularRoute
.withOptions({
uri: 'segment1/segment2/:parameter'
})
.on('end', function () {
assert.file([
'app/scripts/controllers/simpleroute.js',
'test/spec/controllers/simpleroute.js',
'app/views/simpleroute.html'
]);
assert.fileContent(
'app/scripts/app.js',
/when\('\/segment1\/segment2\/\:parameter'/
);
done();
});
});
});