This repository has been archived by the owner on Nov 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from oliviertassinari/add-unit-tests
feat(js): add unit tests
- Loading branch information
Showing
11 changed files
with
112 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/lib | ||
/docs/dist | ||
/flow/interfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
.*/node_modules/fbjs/* | ||
|
||
[libs] | ||
flow/interfaces | ||
|
||
[options] | ||
esproposal.class_instance_fields=enable | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
type TestFunction = ((done: () => void) => void | Promise<mixed>); | ||
|
||
declare var describe : { | ||
(name:string, spec:() => void): void; | ||
only(description:string, spec:() => void): void; | ||
skip(description:string, spec:() => void): void; | ||
timeout(ms:number): void; | ||
}; | ||
|
||
declare var context : typeof describe; | ||
|
||
declare var it : { | ||
(name:string, spec?:TestFunction): void; | ||
only(description:string, spec:TestFunction): void; | ||
skip(description:string, spec:TestFunction): void; | ||
timeout(ms:number): void; | ||
}; | ||
|
||
declare function before(method : TestFunction):void; | ||
declare function beforeEach(method : TestFunction):void; | ||
declare function after(method : TestFunction):void; | ||
declare function afterEach(method : TestFunction):void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// @flow weak | ||
/* eslint-env mocha */ | ||
|
||
import { assert } from 'chai'; | ||
import ServiceWorkerPlugin from './index'; | ||
|
||
function trim(str) { | ||
return str.replace(/^\s+|\s+$/, ''); | ||
} | ||
|
||
describe('ServiceWorkerPlugin', () => { | ||
describe('options: includes', () => { | ||
it('should allow to have a white list parameter', () => { | ||
const filename = 'sw.js'; | ||
const serviceWorkerPlugin = new ServiceWorkerPlugin({ | ||
filename, | ||
includes: ['bar.*'], | ||
}); | ||
|
||
const compilation = { | ||
assets: { | ||
[filename]: { | ||
source: () => '', | ||
}, | ||
'bar.js': {}, | ||
'foo.js': {}, | ||
}, | ||
}; | ||
|
||
return serviceWorkerPlugin | ||
.handleEmit(compilation, { | ||
options: {}, | ||
}, () => {}) | ||
.then(() => { | ||
assert.strictEqual(compilation.assets[filename].source(), trim(` | ||
var serviceWorkerOption = { | ||
"assets": [ | ||
"./bar.js" | ||
] | ||
};`)); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--require babel-register | ||
--reporter dot | ||
--recursive | ||
src/{,**/}*.spec.js |