Skip to content

Commit dc1afd5

Browse files
author
benholloway
committed
remove duplicate descriptions by moving common files outside of spec directory
1 parent b25b3d7 commit dc1afd5

File tree

9 files changed

+112
-288
lines changed

9 files changed

+112
-288
lines changed

test/helpers/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('./angularity-test'),
6+
matchers = require('./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+
};

test/helpers/helper.js

Lines changed: 0 additions & 165 deletions
This file was deleted.

test/helpers/jasmine-matchers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ 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();
75+
var lastLine = text.split(/\r?\n/g).filter(Boolean).pop();
7676
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' :

test/helpers/javascript-task.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict';
2+
3+
var diffMatchers = require('jasmine-diff-matchers');
4+
5+
var helper = require('./angularity-test'),
6+
matchers = require('./jasmine-matchers');
7+
8+
var BUILD_FOLDER = 'app-build';
9+
var TEST_FOLDER = 'app-test';
10+
11+
function expectations(testCase) {
12+
var workingBuildFile = helper.getConcatenation(testCase.cwd, BUILD_FOLDER);
13+
var sourceBuildFile = helper.getConcatenation(testCase.sourceDir, BUILD_FOLDER);
14+
var workingTestFile = helper.getConcatenation(testCase.cwd, TEST_FOLDER);
15+
var sourceTestFile = helper.getConcatenation(testCase.sourceDir, TEST_FOLDER);
16+
17+
// general
18+
expect(testCase.stdout).toBeTask('javascript');
19+
expect(testCase.cwd).toHaveExpectedJsExcept();
20+
21+
// build output
22+
expect(workingBuildFile('index.js')).diffFilePatch(sourceBuildFile('index.js'));
23+
// expect(workingBuildFile('index.js.map' )).diffFilePatch(sourceBuildFile('index.js.map')); // TODO @bholloway solve repeatability of .map files
24+
25+
// test output
26+
expect(workingTestFile('index.js')).diffFilePatch(sourceTestFile('index.js'));
27+
// expect(workingTestFile('index.js.map')).diffFilePatch(sourceTestFile('index.js.map')); // TODO @bholloway solve repeatability of .map files
28+
}
29+
30+
function customMatchers() {
31+
jasmine.addMatchers(diffMatchers.diffPatch);
32+
jasmine.addMatchers({
33+
toBeJsHelpWithError : matchers
34+
.getHelpMatcher(/^\s*The "javascript" task/),
35+
toHaveExpectedJsExcept: matchers
36+
.getFileMatcher(
37+
'app-build/index.js', 'app-build/index.js.map',
38+
'app-test/index.js', 'app-test/index.js.map',
39+
'app-test/karma.conf.js'
40+
)
41+
});
42+
}
43+
44+
module.exports = {
45+
expectations : expectations,
46+
customMatchers: customMatchers
47+
};

test/rebuildExpected.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/specs/tasks/build.spec.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ var diffMatchers = require('jasmine-diff-matchers');
44

55
var helper = require('../../helpers/angularity-test'),
66
matchers = require('../../helpers/jasmine-matchers'),
7-
javascriptSpec = require('./javascript.spec.js'),
8-
cssSpec = require('./css.spec.js');
7+
javascriptTask = require('../../helpers/javascript-task'),
8+
cssTask = require('../../helpers/css-task');
99

1010
var fastIt = helper.jasmineFactory({
1111
before: 0,
@@ -24,9 +24,9 @@ describe('The Angularity build task', function () {
2424

2525
beforeEach(matchers.addMatchers);
2626

27-
beforeEach(javascriptSpec.customMatchers);
27+
beforeEach(javascriptTask.customMatchers);
2828

29-
beforeEach(cssSpec.customMatchers);
29+
beforeEach(cssTask.customMatchers);
3030

3131
beforeEach(customMatchers);
3232

@@ -79,8 +79,8 @@ function expectations(testCase) {
7979
expect(testCase.stdout).toBeTask('build');
8080
expect(testCase.cwd).toHaveFile('app-build/index.html');
8181
expect(workingBuildFile('index.html')).diffFilePatch(sourceBuildFile('index.html'));
82-
javascriptSpec.expectations(testCase);
83-
cssSpec.expectations(testCase);
82+
javascriptTask.expectations(testCase);
83+
cssTask.expectations(testCase);
8484
}
8585

8686
function customMatchers() {
@@ -89,9 +89,4 @@ function customMatchers() {
8989
toBeBuildHelpWithError : matchers
9090
.getHelpMatcher(/^\s*The "build" task/)
9191
});
92-
}
93-
94-
module.exports = {
95-
expectations : expectations,
96-
customMatchers: customMatchers
97-
};
92+
}

test/specs/tasks/css.spec.js

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
'use strict';
22

3-
var diffMatchers = require('jasmine-diff-matchers');
4-
53
var helper = require('../../helpers/angularity-test'),
6-
matchers = require('../../helpers/jasmine-matchers');
4+
matchers = require('../../helpers/jasmine-matchers'),
5+
cssTask = require('../../helpers/css-task');
76

87
var fastIt = helper.jasmineFactory({
98
before: 0,
@@ -21,7 +20,7 @@ describe('The Angularity css task', function () {
2120

2221
beforeEach(matchers.addMatchers);
2322

24-
beforeEach(customMatchers);
23+
beforeEach(cssTask.customMatchers);
2524

2625
beforeEach(helper.getTimeoutSwitch(60000));
2726

@@ -47,31 +46,7 @@ describe('The Angularity css task', function () {
4746
helper.runner.create()
4847
.addSource('minimal-es5')
4948
.addInvocation('css')
50-
.forEach(slowIt(expectations))
49+
.forEach(slowIt(cssTask.expectations))
5150
.finally(done);
5251
});
53-
});
54-
55-
function expectations(testCase) {
56-
var workingBuildFile = helper.getConcatenation(testCase.cwd, BUILD_FOLDER);
57-
var sourceBuildFile = helper.getConcatenation(testCase.sourceDir, BUILD_FOLDER);
58-
expect(testCase.stdout).toBeTask('css');
59-
expect(testCase.cwd).toHaveExpectedCssExcept();
60-
expect(workingBuildFile('index.css')).diffFilePatch(sourceBuildFile('index.css'));
61-
// expect(workingBuildFile('index.css.map')).diffFilePatch(sourceBuildFile('index.css.map')); // TODO @bholloway solve repeatability of .map files
62-
}
63-
64-
function customMatchers() {
65-
jasmine.addMatchers(diffMatchers.diffPatch);
66-
jasmine.addMatchers({
67-
toBeCssHelpWithError : matchers
68-
.getHelpMatcher(/^\s*The "css" task/),
69-
toHaveExpectedCssExcept: matchers
70-
.getFileMatcher('app-build/index.css', 'app-build/index.css.map')
71-
});
72-
}
73-
74-
module.exports = {
75-
expectations : expectations,
76-
customMatchers: customMatchers
77-
};
52+
});

0 commit comments

Comments
 (0)