-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EventStream Puzzler #75
base: sarah-eventstream-puzzler
Are you sure you want to change the base?
EventStream Puzzler #75
Conversation
src/index.ts
Outdated
|
||
export function scoreEventStream(eventStream: ReadonlyArray<event>): highest_score { | ||
return { | ||
events: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a return object here because otherwise my test suite would not run and I have typed the output for the function
src/index.test.ts
Outdated
it('should return an object with an events property', () => { | ||
const actual = scoreEventStream(eventStream); | ||
|
||
expect(actual).toHaveProperty("events"); | ||
}) | ||
|
||
it('should return an object with a score property', () => { | ||
const actual = scoreEventStream(eventStream); | ||
|
||
expect(actual).toHaveProperty("score"); | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two tests can be combined, since you're testing that the return object has the expected properties.
just do both expects in the same test.
src/index.test.ts
Outdated
expect(actual).toHaveProperty("score"); | ||
}) | ||
|
||
it('successfully assess the length of the inputted array', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
future tests should include checks for different region lengths? If not, just add a comment here saying that the default length is 5.
src/index.ts
Outdated
@@ -1 +1,16 @@ | |||
//Define class/functions here | |||
type event = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface
src/index.ts
Outdated
eventType: string | ||
} | ||
|
||
type highest_score = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
high_score -> HighScore
expect(actual).toHaveProperty("score"); | ||
}) | ||
|
||
it('length of events array in return object should be no greater than 5', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the function now accepts the regionLength argument, then we need additional tests to verify expected array lengths. Default vs > vs <
@@ -0,0 +1,13 @@ | |||
export interface event { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export interface event { | |
export interface Event { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interfaces and types should be capialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type EventStream = ReadonlyArray<Event>;
return eventStreamWithScores.map(e => { return e.score }) | ||
} | ||
|
||
export function scoreEventStream(eventStream: ReadonlyArray<event>, subRegionLength: number = 5) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const DEFAULT_SUBREGION_LENGTH = 5
What this is
Red phase tests for eventStream puzzler
Ticket
Sarah-EventStream-Puzzler
Steps to Verify
run
yarn test
in terminalMedia
