Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gcedo committed Jun 8, 2017
0 parents commit df42b56
Show file tree
Hide file tree
Showing 13 changed files with 4,012 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["latest", "flow"]
}
Empty file added .flowconfig
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
57 changes: 57 additions & 0 deletions __test__/EventSource.test.js
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);
});
});
108 changes: 108 additions & 0 deletions flow-typed/npm/babel-cli_vx.x.x.js
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'>;
}
32 changes: 32 additions & 0 deletions flow-typed/npm/babel-preset-flow_vx.x.x.js
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'>;
}
32 changes: 32 additions & 0 deletions flow-typed/npm/babel-preset-latest_vx.x.x.js
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'>;
}
6 changes: 6 additions & 0 deletions flow-typed/npm/flow-bin_v0.x.x.js
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;
}
Loading

0 comments on commit df42b56

Please sign in to comment.