-
Notifications
You must be signed in to change notification settings - Fork 58
/
testDemoCmd.js
74 lines (64 loc) · 2.79 KB
/
testDemoCmd.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
/*
* Copyright 2018 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
/* eslint-env mocha */
const assert = require('assert');
const path = require('path');
const $ = require('shelljs');
const { assertFile, createTestRoot } = require('./utils.js');
const DemoCommand = require('../src/demo.cmd');
const pwd = process.cwd();
describe('Integration test for demo command', () => {
let testDir;
beforeEach(async () => {
testDir = await createTestRoot();
});
afterEach('Change back to original working dir', () => {
process.chdir(pwd);
});
it('demo type simple creates all files', async () => {
await new DemoCommand()
.withDirectory(testDir)
.withName('project1')
.run();
assertFile(path.resolve(testDir, 'project1', '.gitignore'));
assertFile(path.resolve(testDir, 'project1', 'src/html.htl'));
assertFile(path.resolve(testDir, 'project1', 'src/html.pre.js'));
assertFile(path.resolve(testDir, 'project1', 'index.md'));
assertFile(path.resolve(testDir, 'project1', 'src/style.css'));
assertFile(path.resolve(testDir, 'project1', 'src/favicon.ico'));
assertFile(path.resolve(testDir, 'project1', 'helix_logo.png'));
}).timeout(3000);
it('demo type full creates all files', async () => {
await new DemoCommand()
.withDirectory(testDir)
.withName('project1')
.withType('full')
.run();
assertFile(path.resolve(testDir, 'project1', '.gitignore'));
assertFile(path.resolve(testDir, 'project1', 'src/html.htl'));
assertFile(path.resolve(testDir, 'project1', 'src/html.pre.js'));
assertFile(path.resolve(testDir, 'project1', 'index.md'));
assertFile(path.resolve(testDir, 'project1', 'README.md'));
assertFile(path.resolve(testDir, 'project1', 'src/bootstrap.min.css'));
assertFile(path.resolve(testDir, 'project1', 'src/favicon.ico'));
assertFile(path.resolve(testDir, 'project1', 'helix_logo.png'));
}).timeout(3000);
it('demo does not leave any files not checked in', async () => {
await new DemoCommand()
.withDirectory(testDir)
.withName('project2')
.run();
process.chdir(path.resolve(testDir, 'project2'));
const status = $.exec('git status --porcelain', { silent: true });
assert.equal('', status.stdout);
}).timeout(3000);
});