Skip to content

Commit

Permalink
Handling the case where start is not at the front
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-buttner committed Jul 27, 2020
1 parent df256ab commit 185f6ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,32 @@ describe('Generated documents', () => {
expect(isStart(event)).toBeTruthy();
});

it('is a start event when event.type is an array of strings and contains start', () => {
let event: ResolverEvent = generator.generateEvent({
eventType: ['bogus', 'start', 'creation'],
});
expect(isStart(event)).toBeTruthy();

event = generator.generateEvent({
eventType: ['start', 'bogus'],
});
expect(isStart(event)).toBeTruthy();
});

it('is not a start event when event.type is not start', () => {
const event: ResolverEvent = generator.generateEvent({
eventType: ['end'],
});
expect(isStart(event)).toBeFalsy();
});

it('is not a start event when event.type is empty', () => {
const event: ResolverEvent = generator.generateEvent({
eventType: [],
});
expect(isStart(event)).toBeFalsy();
});

it('is not a start event when event.type is bogus', () => {
const event: ResolverEvent = generator.generateEvent({
eventType: ['bogus'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function isStart(event: ResolverEvent): boolean {
}

if (Array.isArray(event.event.type)) {
return event.event.type.length === 1 && event.event.type[0] === 'start';
return event.event.type.includes('start');
}

return event.event.type === 'start';
Expand Down

0 comments on commit 185f6ff

Please sign in to comment.