Skip to content

Commit

Permalink
feat: [#4] NewJobMessage does not have a jor ref
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Feb 17, 2022
1 parent 73af831 commit c01e435
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions __tests__/unit/message.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {JobFinishedMessage, NewJobMessage} from '../../src/message'
import {CommitHash} from '../../src/commit-hash'
import {NewJobMessage} from '../../src/message'

describe('Message', () => {
it('should have payload', () => {
it('should have a payload', () => {
const message = new NewJobMessage('payload')
expect(message.getPayload()).toBe('payload')
})

it('could have an optional reference (commit hash) to another job', () => {
const hash = new CommitHash('f1a69d48a01cc130a64aeac5eaf762e4ba685de7')

const message = new NewJobMessage('payload', hash)
const message = new JobFinishedMessage('payload', hash)

expect(message.getJobRef().equalsTo(hash)).toBe(true)
})
Expand All @@ -26,7 +26,7 @@ describe('Message', () => {
expect(messageWithoutJobRef.hasJobRef()).toBe(false)

const hash = new CommitHash('f1a69d48a01cc130a64aeac5eaf762e4ba685de7')
const messageWithJobRef = new NewJobMessage('payload', hash)
const messageWithJobRef = new JobFinishedMessage('payload', hash)
expect(messageWithJobRef.hasJobRef()).toBe(true)
})
})
3 changes: 3 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export abstract class Message {
}

export class NewJobMessage extends Message {
constructor(payload: string) {
super(payload, nullCommitHash())
}

getKey(): MessageKey {
return new MessageKey('🈺')
}
Expand Down

0 comments on commit c01e435

Please sign in to comment.