-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
113 lines (107 loc) · 3.65 KB
/
test.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
'use strict';
/* eslint-env mocha */
/* eslint-disable func-names */
var path = require('path');
var helpers = require('yeoman-test');
var assert = require('yeoman-assert');
var R = require('ramda');
var depsObject = require('deps-object');
var testFrameworksHash = require('./app/test-frameworks');
var defaults = {
moduleName: 'module',
githubUsername: 'username',
website: 'test.com',
moduleDesc: 'Your awsm module!',
appveyorSupport: true
};
it('generates expected files', function (done) {
helpers.run(path.join(__dirname, './app'))
.withOptions({ all: true })
.withPrompts(R.merge(defaults, { moduleTest: 'tape' }))
.on('end', function () {
assert.file([
'.editorconfig',
'.gitignore',
'.travis.yml',
'appveyor.yml',
'.babelrc',
'package.json',
'index.js',
'test.js',
'README.md',
'.eslintrc.json',
'CHANGELOG.md',
'.git'
]);
assert.fileContent('README.md', '[![Unix Build Status][travis-image]][travis-url]');
assert.fileContent('README.md', '[![Windows Build Status][appveyor-image]][appveyor-url]');
done();
});
});
it('generates expected files without appveyor', function (done) {
helpers.run(path.join(__dirname, './app'))
.withOptions({ all: true })
.withPrompts(R.merge(defaults, { appveyorSupport: false }))
.on('end', function () {
assert.noFile('appveyor.yml');
assert.fileContent('README.md', '[![Build Status][travis-image]][travis-url]');
done();
});
});
it('generates all needed for mocha', function (done) {
var testFramework = R.prop('mocha', testFrameworksHash);
var scripts = R.pick(['test', 'tdd'], testFramework);
var deps = R.prop('deps', testFramework);
depsObject(deps).then(function (devDeps) {
helpers.run(path.join(__dirname, './app'))
.withOptions({ all: true })
.withPrompts(R.merge(defaults, { moduleTest: 'mocha' }))
.on('end', function () {
assert.jsonFileContent('package.json', {
scripts: scripts,
devDependencies: devDeps
});
assert.fileContent('test.js', /mocha/);
assert.noJsonFileContent('.eslintrc.json', { parser: 'babel-eslint' });
done();
});
});
});
it('generates all needed for tape', function (done) {
var testFramework = R.prop('tape', testFrameworksHash);
var scripts = R.pick(['test', 'tdd'], testFramework);
var deps = R.prop('deps', testFramework);
depsObject(deps).then(function (devDeps) {
helpers.run(path.join(__dirname, './app'))
.withOptions({ all: true, debug: true })
.withPrompts(R.merge(defaults, { moduleTest: 'tape' }))
.on('end', function () {
assert.jsonFileContent('package.json', {
scripts: scripts,
devDependencies: devDeps
});
assert.fileContent('test.js', /tape/);
assert.noJsonFileContent('.eslintrc.json', { parser: 'babel-eslint' });
done();
});
});
});
it('generates all needed for ava', function (done) {
var testFramework = R.prop('ava', testFrameworksHash);
var scripts = R.pick(['test', 'tdd'], testFramework);
var deps = R.prop('deps', testFramework);
depsObject(deps).then(function (devDeps) {
helpers.run(path.join(__dirname, './app'))
.withOptions({ all: true })
.withPrompts(R.merge(defaults, { moduleTest: 'ava' }))
.on('end', function () {
assert.jsonFileContent('package.json', {
scripts: scripts,
devDependencies: devDeps
});
assert.fileContent('test.js', /ava/);
assert.jsonFileContent('.eslintrc.json', { parser: 'babel-eslint' });
done();
});
});
});