Skip to content

Commit 7f01ad8

Browse files
committed
Merge branch 'integration-test-refactor'
Conflicts: npm-shrinkwrap.json package.json test/expected/minimal-es5-unminified/app-build/index.css test/expected/minimal-es5-unminified/app-build/index.css.map test/expected/minimal-es5-unminified/app-build/index.js test/expected/minimal-es5-unminified/app-build/index.js.map test/expected/minimal-es5-unminified/app-release/index.css test/expected/minimal-es5-unminified/app-release/index.css.map test/expected/minimal-es5-unminified/app-release/index.js test/expected/minimal-es5-unminified/app-release/index.js.map test/expected/minimal-es5-unminified/app-release/vendor/manifest.json test/expected/minimal-es5-unminified/app-test/index.js test/expected/minimal-es5-unminified/app-test/index.js.map test/expected/minimal-es5-unminified/app-test/karma.conf.js test/expected/minimal-es5/app-test/index.js test/expected/minimal-es5/app-test/index.js.map test/expected/minimal-es5/app-test/karma.conf.js test/helpers/cli-test.js test/helpers/helper.js test/helpers/jasmine-matchers.js test/specs/cli.spec.js test/specs/tasks/build.spec.js test/specs/tasks/init.spec.js test/specs/tasks/release.spec.js test/specs/tasks/test.spec.js
2 parents 9e1797e + dfd531f commit 7f01ad8

File tree

16 files changed

+284
-81
lines changed

16 files changed

+284
-81
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/.idea
22
/node_modules
3-
/test/test-temp
3+
/test/*temp
44
npm-debug.log

.jshintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
"maxparams": 20,
2222
"maxdepth": 5,
2323
"maxlen": 120,
24-
"node": true
24+
"node": true,
25+
"jasmine": true
2526
}

appveyor.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
environment:
22
matrix:
3-
- nodejs_version: "0.11"
43
- nodejs_version: "0.10"
5-
- nodejs_version: "0.8"
64

75
matrix:
86
fast_finish: true
9-
allow_failures:
10-
- nodejs_version: "0.11"
11-
- nodejs_version: "0.8"
127

138
install:
149
- ps: Install-Product node $env:nodejs_version
1510
- npm -g install npm@2
1611
- set PATH=%APPDATA%\npm;%PATH%
17-
- npm i -g
18-
- npm i -g jasmine-node
19-
- node -v
20-
- npm -v
21-
- jasmine-node --version
2212

2313
test_script:
24-
- jasmine-node --verbose --test-dir C:\projects\node-angularity\test
14+
- node -v
15+
- npm -v
16+
- npm i -g
17+
- npm link
18+
- angularity -v
19+
- npm test
2520

2621
build: off

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"es6",
1313
"esnext",
1414
"browserify",
15-
"es6ify"
15+
"babel"
1616
],
1717
"scripts": {
1818
"test": "node node_modules/jasmine-node/bin/jasmine-node --verbose --captureExceptions test/specs"
@@ -86,6 +86,7 @@
8686
"mime": "latest",
8787
"minifyify": "latest",
8888
"minimatch": "latest",
89+
"ncp": "latest",
8990
"node-sass": "latest",
9091
"pretty-hrtime": "latest",
9192
"q": "latest",

test/expected/minimal-es5-unminified/app-test/karma.conf.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
module.exports = function(config) {
88
config.set({
99
// base path, that will be used to resolve files and exclude
10-
basePath: '/Users/benholloway/Documents/WebstormProjects/angularity/node-angularity/test/expected/minimal-es5-unminified',
10+
basePath: '%redacted%',
1111

1212
//make sure we use karma-jasmine as the test framework
1313
frameworks: ['jasmine'],
@@ -41,12 +41,14 @@ module.exports = function(config) {
4141
// installation and thus need to be registered manually
4242
// append to existing value to preserve plugins loaded automatically
4343
plugins: [].concat(config.plugins).concat([
44-
44+
require("%redacted%")
4545
]),
4646

4747
// use dots reporter, as travis terminal does not support escaping sequences
4848
// possible values: 'dots', 'progress', 'junit', 'teamcity'
49-
reporters: [].concat([]),
49+
reporters: [].concat([
50+
'angularity'
51+
]),
5052

5153
// web server port
5254
port: 61680,

test/expected/minimal-es5/app-test/karma.conf.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
module.exports = function(config) {
88
config.set({
99
// base path, that will be used to resolve files and exclude
10-
basePath: '/Users/benholloway/Documents/WebstormProjects/angularity/node-angularity/test/expected/minimal-es5',
10+
basePath: '%redacted%',
1111

1212
//make sure we use karma-jasmine as the test framework
1313
frameworks: ['jasmine'],
@@ -41,12 +41,14 @@ module.exports = function(config) {
4141
// installation and thus need to be registered manually
4242
// append to existing value to preserve plugins loaded automatically
4343
plugins: [].concat(config.plugins).concat([
44-
44+
require("%redacted%")
4545
]),
4646

4747
// use dots reporter, as travis terminal does not support escaping sequences
4848
// possible values: 'dots', 'progress', 'junit', 'teamcity'
49-
reporters: [].concat([]),
49+
reporters: [].concat([
50+
'angularity'
51+
]),
5052

5153
// web server port
5254
port: 61680,

test/helpers/jasmine-matchers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ function getHelpMatcher(regexp) {
7272
return {
7373
compare: function compare(buffer, expectError) {
7474
var text = buffer.toString();
75-
var lastLine = text.split(/\n/g).filter(Boolean).pop();
76-
var hasError = /^\s*\[Error\:[^\]]*]/.test(lastLine);
75+
var lastLine = text.split(/\r?\n/g).filter(Boolean).pop();
76+
var hasError = /^\s*\[Error\:[^\]]*]|^\s*Unknown argument\:.*$/.test(lastLine); // error or unknown argument
7777
var message =
7878
!(regexp.test(text)) ? 'Help message does not match expectation' :
7979
(hasError !== expectError) ? ['Help', (expectError ? 'expected' : 'did not expect'), 'an error',

test/specs/cli.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var fastIt = helper.jasmineFactory({
1111

1212
describe('The Angularity cli interface', function () {
1313

14-
beforeEach(helper.getTimeoutSwitch(30000));
14+
beforeEach(helper.getTimeoutSwitch(60000));
1515

1616
afterEach(helper.getTimeoutSwitch());
1717

test/specs/tasks/build.spec.js

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
var diffMatchers = require('jasmine-diff-matchers');
44

5-
var helper = require('../../helpers/angularity-test'),
6-
matchers = require('../../helpers/jasmine-matchers');
5+
var helper = require('../../helpers/angularity-test'),
6+
matchers = require('../../helpers/jasmine-matchers'),
7+
javascriptTask = require('./javascript-task'),
8+
cssTask = require('./css-task');
79

810
var fastIt = helper.jasmineFactory({
911
before: 0,
@@ -22,9 +24,13 @@ describe('The Angularity build task', function () {
2224

2325
beforeEach(matchers.addMatchers);
2426

27+
beforeEach(javascriptTask.customMatchers);
28+
29+
beforeEach(cssTask.customMatchers);
30+
2531
beforeEach(customMatchers);
2632

27-
beforeEach(helper.getTimeoutSwitch(30000));
33+
beforeEach(helper.getTimeoutSwitch(60000));
2834

2935
afterEach(helper.getTimeoutSwitch());
3036

@@ -40,7 +46,8 @@ describe('The Angularity build task', function () {
4046

4147
function expectations(testCase) {
4248
expect([testCase.cwd, BUILD_FOLDER]).toBeEmptyDirectory();
43-
expect(testCase.stderr).toBeHelpWithError(false);
49+
expect([testCase.cwd, TEST_FOLDER ]).toBeEmptyDirectory();
50+
expect(testCase.stderr).toBeBuildHelpWithError(false);
4451
}
4552
});
4653

@@ -69,48 +76,17 @@ describe('The Angularity build task', function () {
6976
function expectations(testCase) {
7077
var workingBuildFile = helper.getConcatenation(testCase.cwd, BUILD_FOLDER);
7178
var sourceBuildFile = helper.getConcatenation(testCase.sourceDir, BUILD_FOLDER);
72-
var workingTestFile = helper.getConcatenation(testCase.cwd, TEST_FOLDER);
73-
var sourceTestFile = helper.getConcatenation(testCase.sourceDir, TEST_FOLDER);
74-
75-
// general
76-
expect(testCase.stdout).toBeTask(['build', 'javascript', 'css']);
77-
expect(testCase.cwd).toHaveExpectedItemsExcept();
78-
79-
// build output
79+
expect(testCase.stdout).toBeTask('build');
80+
expect(testCase.cwd).toHaveFile('app-build/index.html');
8081
expect(workingBuildFile('index.html')).diffFilePatch(sourceBuildFile('index.html'));
81-
expect(workingBuildFile('index.js')).diffFilePatch(sourceBuildFile('index.js'));
82-
expect(workingBuildFile('index.css')).diffFilePatch(sourceBuildFile('index.css'));
83-
// expect(workingBuildFile('index.js.map' )).diffFilePatch(sourceBuildFile('index.js.map')); // TODO @bholloway solve repeatability of .map files
84-
// expect(workingBuildFile('index.css.map')).diffFilePatch(sourceBuildFile('index.css.map')); // TODO @bholloway solve repeatability of .map files
85-
86-
// must remove basePath to allow karma.conf.js to be correctly diff'd
87-
var replace = helper.replacer()
88-
.add(/^\s*basePath:.*$/gm, '')
89-
.add(/\\{2}/g, '/')
90-
.commit();
91-
92-
// test output
93-
expect(replace(workingTestFile('karma.conf.js'))).diffPatch(replace(sourceTestFile('karma.conf.js')));
94-
expect(workingTestFile('index.js')).diffFilePatch(sourceTestFile('index.js'));
95-
// expect(workingTestFile('index.js.map')).diffFilePatch(sourceTestFile('index.js.map')); // TODO @bholloway solve repeatability of .map files
82+
javascriptTask.expectations(testCase);
83+
cssTask.expectations(testCase);
9684
}
9785

9886
function customMatchers() {
9987
jasmine.addMatchers(diffMatchers.diffPatch);
10088
jasmine.addMatchers({
101-
toBeHelpWithError : matchers
102-
.getHelpMatcher(/^\s*The "build" task/),
103-
toHaveExpectedItemsExcept: matchers
104-
.getFileMatcher(
105-
'app-build/index.html',
106-
'app-build/index.js', 'app-build/index.js.map',
107-
'app-build/index.css', 'app-build/index.css.map',
108-
'app-test/karma.conf.js',
109-
'app-test/index.js', 'app-test/index.js.map'
110-
)
89+
toBeBuildHelpWithError : matchers
90+
.getHelpMatcher(/^\s*The "build" task/)
11191
});
112-
}
113-
114-
module.exports = {
115-
expectations: expectations
116-
};
92+
}

test/specs/tasks/css-task.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
3+
var diffMatchers = require('jasmine-diff-matchers');
4+
5+
var helper = require('./../../helpers/angularity-test'),
6+
matchers = require('./../../helpers/jasmine-matchers');
7+
8+
var BUILD_FOLDER = 'app-build';
9+
10+
function expectations(testCase) {
11+
var workingBuildFile = helper.getConcatenation(testCase.cwd, BUILD_FOLDER);
12+
var sourceBuildFile = helper.getConcatenation(testCase.sourceDir, BUILD_FOLDER);
13+
expect(testCase.stdout).toBeTask('css');
14+
expect(testCase.cwd).toHaveExpectedCssExcept();
15+
expect(workingBuildFile('index.css')).diffFilePatch(sourceBuildFile('index.css'));
16+
// expect(workingBuildFile('index.css.map')).diffFilePatch(sourceBuildFile('index.css.map')); // TODO @bholloway solve repeatability of .map files
17+
}
18+
19+
function customMatchers() {
20+
jasmine.addMatchers(diffMatchers.diffPatch);
21+
jasmine.addMatchers({
22+
toBeCssHelpWithError : matchers
23+
.getHelpMatcher(/^\s*The "css" task/),
24+
toHaveExpectedCssExcept: matchers
25+
.getFileMatcher('app-build/index.css', 'app-build/index.css.map')
26+
});
27+
}
28+
29+
module.exports = {
30+
expectations : expectations,
31+
customMatchers: customMatchers
32+
};

0 commit comments

Comments
 (0)