-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit df42b56
Showing
13 changed files
with
4,012 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["latest", "flow"] | ||
} |
Empty file.
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 @@ | ||
node_modules/ |
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,57 @@ | ||
// @flow | ||
import EventSource from '../src/EventSource'; | ||
|
||
const URL = 'https://example.com/events'; | ||
const EVENT_NAME = 'EVENT_NAME'; | ||
const messageEvent = { | ||
data: 'message event data', | ||
}; | ||
|
||
describe('constructor', () => { | ||
let eventSource; | ||
beforeAll(() => { | ||
eventSource = new EventSource(URL); | ||
}); | ||
|
||
it(`should set the url to ${URL}`, () => { | ||
expect(eventSource.url).toBe(URL); | ||
}); | ||
|
||
it('should set withCredentials to false', () => { | ||
expect(eventSource.withCredentials).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('add a listener', () => { | ||
let eventSource; | ||
let listener; | ||
let emitter; | ||
|
||
beforeAll(() => { | ||
listener = jest.fn(); | ||
eventSource = new EventSource(URL); | ||
emitter = eventSource.__emitter; | ||
eventSource.addEventListener(EVENT_NAME, listener); | ||
}); | ||
|
||
it('should add an event listener', () => { | ||
expect(emitter.listeners(EVENT_NAME)).toEqual([listener]); | ||
}); | ||
|
||
it('should call the listener', () => { | ||
eventSource.emit(EVENT_NAME, messageEvent); | ||
expect(listener).toHaveBeenCalledWith(messageEvent.data); | ||
}); | ||
}); | ||
|
||
describe('close', () => { | ||
let eventSource; | ||
beforeAll(() => { | ||
eventSource = new EventSource(URL); | ||
}); | ||
|
||
it('should set readyState to 2 (CLOSED)', () => { | ||
eventSource.close(); | ||
expect(eventSource.readyState).toBe(2); | ||
}); | ||
}); |
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,108 @@ | ||
// flow-typed signature: 25c5e9a036a3e199649f88360d74aba9 | ||
// flow-typed version: <<STUB>>/babel-cli_v^6.24.1/flow_v0.47.0 | ||
|
||
/** | ||
* This is an autogenerated libdef stub for: | ||
* | ||
* 'babel-cli' | ||
* | ||
* Fill this stub out by replacing all the `any` types. | ||
* | ||
* Once filled out, we encourage you to share your work with the | ||
* community by sending a pull request to: | ||
* https://github.com/flowtype/flow-typed | ||
*/ | ||
|
||
declare module 'babel-cli' { | ||
declare module.exports: any; | ||
} | ||
|
||
/** | ||
* We include stubs for each file inside this npm package in case you need to | ||
* require those files directly. Feel free to delete any files that aren't | ||
* needed. | ||
*/ | ||
declare module 'babel-cli/bin/babel-doctor' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'babel-cli/bin/babel-external-helpers' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'babel-cli/bin/babel-node' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'babel-cli/bin/babel' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'babel-cli/lib/_babel-node' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'babel-cli/lib/babel-external-helpers' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'babel-cli/lib/babel-node' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'babel-cli/lib/babel/dir' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'babel-cli/lib/babel/file' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'babel-cli/lib/babel/index' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'babel-cli/lib/babel/util' { | ||
declare module.exports: any; | ||
} | ||
|
||
// Filename aliases | ||
declare module 'babel-cli/bin/babel-doctor.js' { | ||
declare module.exports: $Exports<'babel-cli/bin/babel-doctor'>; | ||
} | ||
declare module 'babel-cli/bin/babel-external-helpers.js' { | ||
declare module.exports: $Exports<'babel-cli/bin/babel-external-helpers'>; | ||
} | ||
declare module 'babel-cli/bin/babel-node.js' { | ||
declare module.exports: $Exports<'babel-cli/bin/babel-node'>; | ||
} | ||
declare module 'babel-cli/bin/babel.js' { | ||
declare module.exports: $Exports<'babel-cli/bin/babel'>; | ||
} | ||
declare module 'babel-cli/index' { | ||
declare module.exports: $Exports<'babel-cli'>; | ||
} | ||
declare module 'babel-cli/index.js' { | ||
declare module.exports: $Exports<'babel-cli'>; | ||
} | ||
declare module 'babel-cli/lib/_babel-node.js' { | ||
declare module.exports: $Exports<'babel-cli/lib/_babel-node'>; | ||
} | ||
declare module 'babel-cli/lib/babel-external-helpers.js' { | ||
declare module.exports: $Exports<'babel-cli/lib/babel-external-helpers'>; | ||
} | ||
declare module 'babel-cli/lib/babel-node.js' { | ||
declare module.exports: $Exports<'babel-cli/lib/babel-node'>; | ||
} | ||
declare module 'babel-cli/lib/babel/dir.js' { | ||
declare module.exports: $Exports<'babel-cli/lib/babel/dir'>; | ||
} | ||
declare module 'babel-cli/lib/babel/file.js' { | ||
declare module.exports: $Exports<'babel-cli/lib/babel/file'>; | ||
} | ||
declare module 'babel-cli/lib/babel/index.js' { | ||
declare module.exports: $Exports<'babel-cli/lib/babel/index'>; | ||
} | ||
declare module 'babel-cli/lib/babel/util.js' { | ||
declare module.exports: $Exports<'babel-cli/lib/babel/util'>; | ||
} |
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,32 @@ | ||
// flow-typed signature: ecc5c7711455066a3b2cda7e62a4361a | ||
// flow-typed version: <<STUB>>/babel-preset-flow_v^6.23.0/flow_v0.47.0 | ||
|
||
/** | ||
* This is an autogenerated libdef stub for: | ||
* | ||
* 'babel-preset-flow' | ||
* | ||
* Fill this stub out by replacing all the `any` types. | ||
* | ||
* Once filled out, we encourage you to share your work with the | ||
* community by sending a pull request to: | ||
* https://github.com/flowtype/flow-typed | ||
*/ | ||
|
||
declare module 'babel-preset-flow' { | ||
declare module.exports: any; | ||
} | ||
|
||
/** | ||
* We include stubs for each file inside this npm package in case you need to | ||
* require those files directly. Feel free to delete any files that aren't | ||
* needed. | ||
*/ | ||
declare module 'babel-preset-flow/lib/index' { | ||
declare module.exports: any; | ||
} | ||
|
||
// Filename aliases | ||
declare module 'babel-preset-flow/lib/index.js' { | ||
declare module.exports: $Exports<'babel-preset-flow/lib/index'>; | ||
} |
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,32 @@ | ||
// flow-typed signature: 5367ef410d8520052bbb4c2a74f8b7a5 | ||
// flow-typed version: <<STUB>>/babel-preset-latest_v^6.24.1/flow_v0.47.0 | ||
|
||
/** | ||
* This is an autogenerated libdef stub for: | ||
* | ||
* 'babel-preset-latest' | ||
* | ||
* Fill this stub out by replacing all the `any` types. | ||
* | ||
* Once filled out, we encourage you to share your work with the | ||
* community by sending a pull request to: | ||
* https://github.com/flowtype/flow-typed | ||
*/ | ||
|
||
declare module 'babel-preset-latest' { | ||
declare module.exports: any; | ||
} | ||
|
||
/** | ||
* We include stubs for each file inside this npm package in case you need to | ||
* require those files directly. Feel free to delete any files that aren't | ||
* needed. | ||
*/ | ||
declare module 'babel-preset-latest/lib/index' { | ||
declare module.exports: any; | ||
} | ||
|
||
// Filename aliases | ||
declare module 'babel-preset-latest/lib/index.js' { | ||
declare module.exports: $Exports<'babel-preset-latest/lib/index'>; | ||
} |
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,6 @@ | ||
// flow-typed signature: 6a5610678d4b01e13bbfbbc62bdaf583 | ||
// flow-typed version: 3817bc6980/flow-bin_v0.x.x/flow_>=v0.25.x | ||
|
||
declare module "flow-bin" { | ||
declare module.exports: string; | ||
} |
Oops, something went wrong.