11'use strict' ;
22
3- var fs = require ( 'fs' ) ,
4- path = require ( 'path' ) ;
5-
6- var jasmineDiffMatchers = require ( 'jasmine-diff-matchers' ) ;
3+ var diffMatchers = require ( 'jasmine-diff-matchers' ) ;
74
85var helper = require ( '../../helpers/angularity-test' ) ,
96 matchers = require ( '../../helpers/jasmine-matchers' ) ;
@@ -33,7 +30,7 @@ describe('The Angularity build task', function () {
3330
3431 afterEach ( helper . cleanUp ) ;
3532
36- describe ( 'with help switch ' , function ( done ) {
33+ describe ( 'should display help when requested ' , function ( done ) {
3734 helper . runner . create ( )
3835 . addInvocation ( 'build --help' )
3936 . addInvocation ( 'build -h' )
@@ -47,7 +44,7 @@ describe('The Angularity build task', function () {
4744 }
4845 } ) ;
4946
50- describe ( 'with the minimal-es5 project ' , function ( done ) {
47+ describe ( 'should operate minified (by default) ' , function ( done ) {
5148 helper . runner . create ( )
5249 . addSource ( 'minimal-es5' )
5350 . addInvocation ( 'build' )
@@ -57,7 +54,7 @@ describe('The Angularity build task', function () {
5754 . finally ( done ) ;
5855 } ) ;
5956
60- describe ( 'with the minimal-es5 project unminified' , function ( done ) {
57+ describe ( 'should operate unminified' , function ( done ) {
6158 helper . runner . create ( )
6259 . addSource ( 'minimal-es5-unminified' )
6360 . addInvocation ( 'build --unminified' )
@@ -80,13 +77,14 @@ function expectations(testCase) {
8077 expect ( testCase . cwd ) . toHaveExpectedItemsExcept ( ) ;
8178
8279 // build output
80+ expect ( workingBuildFile ( 'index.html' ) ) . diffFilePatch ( sourceBuildFile ( 'index.html' ) ) ;
8381 expect ( workingBuildFile ( 'index.js' ) ) . diffFilePatch ( sourceBuildFile ( 'index.js' ) ) ;
8482 expect ( workingBuildFile ( 'index.css' ) ) . diffFilePatch ( sourceBuildFile ( 'index.css' ) ) ;
8583// expect(workingBuildFile('index.js.map' )).diffFilePatch(sourceBuildFile('index.js.map')); // TODO @bholloway solve repeatability of .map files
8684// expect(workingBuildFile('index.css.map')).diffFilePatch(sourceBuildFile('index.css.map')); // TODO @bholloway solve repeatability of .map files
8785
88- // must remove basePath to allow karam .conf.js to be correctly diff'd
89- var replace = replacer ( )
86+ // must remove basePath to allow karma .conf.js to be correctly diff'd
87+ var replace = helper . replacer ( )
9088 . add ( / ^ \s * b a s e P a t h : .* $ / gm, '' )
9189 . add ( / \\ { 2 } / g, '/' )
9290 . commit ( ) ;
@@ -95,11 +93,10 @@ function expectations(testCase) {
9593 expect ( replace ( workingTestFile ( 'karma.conf.js' ) ) ) . diffPatch ( replace ( sourceTestFile ( 'karma.conf.js' ) ) ) ;
9694 expect ( workingTestFile ( 'index.js' ) ) . diffFilePatch ( sourceTestFile ( 'index.js' ) ) ;
9795// expect(workingTestFile('index.js.map')).diffFilePatch(sourceTestFile('index.js.map')); // TODO @bholloway solve repeatability of .map files
98-
9996}
10097
10198function customMatchers ( ) {
102- jasmine . addMatchers ( jasmineDiffMatchers . diffPatch ) ;
99+ jasmine . addMatchers ( diffMatchers . diffPatch ) ;
103100 jasmine . addMatchers ( {
104101 toBeHelpWithError : matchers
105102 . getHelpMatcher ( / ^ \s * T h e " b u i l d " t a s k / ) ,
@@ -114,36 +111,6 @@ function customMatchers() {
114111 } ) ;
115112}
116113
117- function replacer ( ) {
118- var list = [ ] ;
119- var self = {
120- add : function ( before , after ) {
121- list . push ( {
122- before : before ,
123- after : after
124- } ) ;
125- return self ;
126- } ,
127- commit : function ( ) {
128- return function ( pathElements ) {
129- var filePath = path . resolve . apply ( path , [ ] . concat ( pathElements ) ) ;
130- var text = fs . existsSync ( filePath ) && fs . readFileSync ( filePath ) . toString ( ) ;
131- function replaceSingle ( item ) {
132- if ( text ) {
133- if ( typeof item . before === 'string' ) {
134- while ( text . indexOf ( item . before ) >= 0 ) {
135- text = text . replace ( item . before , item . after ) ;
136- }
137- } else if ( ( typeof item . before === 'object' ) && ( 'test' in item . before ) ) {
138- text = text . replace ( item . before , item . after ) ;
139- }
140- }
141- return text ;
142- }
143- list . forEach ( replaceSingle ) ;
144- return text ;
145- } ;
146- }
147- } ;
148- return self ;
149- }
114+ module . exports = {
115+ expectations : expectations
116+ } ;
0 commit comments