22
33var 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
810var 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 () {
6976function 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 * b a s e P a t h : .* $ / 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
9886function customMatchers ( ) {
9987 jasmine . addMatchers ( diffMatchers . diffPatch ) ;
10088 jasmine . addMatchers ( {
101- toBeHelpWithError : matchers
102- . getHelpMatcher ( / ^ \s * T h e " b u i l d " t a s k / ) ,
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 * T h e " b u i l d " t a s k / )
11191 } ) ;
112- }
113-
114- module . exports = {
115- expectations : expectations
116- } ;
92+ }
0 commit comments