-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathapp.integration.js
More file actions
121 lines (112 loc) · 3.57 KB
/
Copy pathapp.integration.js
File metadata and controls
121 lines (112 loc) · 3.57 KB
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
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: @loopback/cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const generator = path.join(__dirname, '../../../generators/app');
const props = {
name: 'my-app',
description: 'My app for LoopBack 4',
};
const tests = require('../lib/project-generator')(
generator,
props,
'application',
);
const baseTests = require('../lib/base-generator')(generator);
describe('app-generator extending BaseGenerator', baseTests);
describe('generator-loopback4:app', tests);
describe('app-generator specific files', () => {
before(() => {
return helpers.run(generator).withPrompts(props);
});
it('generates all the proper files', () => {
assert.file('src/application.ts');
assert.fileContent(
'src/application.ts',
/class MyAppApplication extends BootMixin\(/,
);
assert.fileContent(
'src/application.ts',
/ServiceMixin\(RepositoryMixin\(RestApplication\)\)/,
);
assert.fileContent('src/application.ts', /constructor\(/);
assert.fileContent('src/application.ts', /this.projectRoot = __dirname/);
assert.file('src/index.ts');
assert.fileContent('src/index.ts', /new MyAppApplication/);
assert.fileContent('src/index.ts', /await app.start\(\);/);
assert.file('src/controllers/ping.controller.ts');
assert.fileContent(
'src/controllers/ping.controller.ts',
/export class PingController/,
);
assert.fileContent('src/controllers/ping.controller.ts', /@inject/);
assert.fileContent(
'src/controllers/ping.controller.ts',
/@get\('\/ping'\)/,
);
assert.fileContent('src/controllers/ping.controller.ts', /ping\(\)/);
assert.fileContent(
'src/controllers/ping.controller.ts',
/\'\@loopback\/rest\'/,
);
});
});
describe('app-generator with --applicationName', () => {
before(() => {
return helpers
.run(generator)
.withOptions({applicationName: 'MyApp'})
.withPrompts(props);
});
it('generates all the proper files', () => {
assert.file('src/application.ts');
assert.fileContent('src/application.ts', /class MyApp extends BootMixin\(/);
});
it('generates the application with RepositoryMixin', () => {
assert.file('src/application.ts');
assert.fileContent(
'src/application.ts',
/RepositoryMixin\(RestApplication\)/,
);
});
});
// The test takes about 1 min to install dependencies
function testFormat() {
before(function() {
this.timeout(90 * 1000);
return helpers
.run(generator)
.withOptions({
applicationName: 'MyApp',
format: true,
// Make sure `npm install` happens
skipInstall: false,
// Disable npm log and progress bar
npmInstall: {silent: true, progress: false},
// Disable npm stdio
spawn: {
stdio: 'ignore',
},
})
.withPrompts(props);
});
it('generates all the proper files', () => {
assert.file('src/application.ts');
assert.fileContent('src/application.ts', /class MyApp extends BootMixin\(/);
});
it('generates the application with RepositoryMixin', () => {
assert.file('src/application.ts');
assert.fileContent(
'src/application.ts',
/RepositoryMixin\(RestApplication\)/,
);
});
}
// Skip the test for CI
process.env.CI && !process.env.DEBUG
? describe.skip
: describe('app-generator with --format', testFormat);