Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzach committed Apr 27, 2020
1 parent c179f39 commit b185757
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Expand Up @@ -6,16 +6,8 @@ const mockOptions = {
iosWriteKey: 'ios-write-key',
};

it(`initializes`, () => {
console.log(Object.keys(ExponentSegment));
it(`initializes once for android`, () => {
Segment.initialize(mockOptions);

expect(ExponentSegment.initialize).toHaveBeenCalledWith(mockOptions.androidWriteKey);
expect(ExponentSegment.initialize).not.toHaveBeenCalled();
});

it(`does not initialize`, () => {
Segment.initialize({ iosWriteKey: 'ios-write-key' });

expect(ExponentSegment.initialize).not.toHaveBeenCalled();
expect(ExponentSegment.initialize).toHaveBeenCalledTimes(1);
});
Expand Up @@ -6,14 +6,18 @@ const mockOptions = {
iosWriteKey: 'ios-write-key',
};

it(`initializes`, () => {
it(`initializes once for ios`, () => {
Segment.initialize(mockOptions);
expect(ExponentSegment.initialize).toHaveBeenCalledWith(mockOptions.iosWriteKey);
expect(ExponentSegment.initialize).not.toHaveBeenCalled();
expect(ExponentSegment.initialize).toHaveBeenCalledTimes(1);
});

it(`does not initialize`, () => {
Segment.initialize({ androidWriteKey: 'android-write-key' });
it(`calling with an empty object results in error`, () => {
expect(() => {
Segment.initialize({});
}).toThrowError(
new Error('You must provide a platform-specific write key to initialize Segment.')
);

expect(ExponentSegment.initialize).not.toHaveBeenCalled();
expect(ExponentSegment.initialize).toHaveBeenCalledTimes(0);
});

0 comments on commit b185757

Please sign in to comment.