generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ccfeb8
commit 2f22e0a
Showing
17 changed files
with
376 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {JobId, nullJobId} from '../../src/job-id' | ||
|
||
describe('JobId', () => { | ||
it('should contain the Id of a Job', () => { | ||
const jobId = new JobId(42) | ||
|
||
expect(jobId.getId()).toBe(42) | ||
}) | ||
|
||
it('should fail when using invalid job value', () => { | ||
const negativeJobId = (): JobId => { | ||
return new JobId(-2) | ||
} | ||
const NaNJobId = (): JobId => { | ||
return new JobId(NaN) | ||
} | ||
const zeroJobId = (): JobId => { | ||
return new JobId(0) | ||
} | ||
|
||
expect(negativeJobId).toThrowError() | ||
expect(NaNJobId).toThrowError() | ||
expect(zeroJobId).not.toThrowError() | ||
}) | ||
|
||
it('should compare two JobIds', () => { | ||
const jobId1 = new JobId(42) | ||
const jobId2 = new JobId(43) | ||
const jobId3 = new JobId(42) | ||
|
||
expect(jobId1.equalsTo(jobId2)).toBe(false) | ||
expect(jobId1.equalsTo(jobId3)).toBe(true) | ||
}) | ||
|
||
it('should be nullable', () => { | ||
const nullObject = nullJobId() | ||
|
||
expect(nullObject.isNull()).toBe(true) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
import {JobFinishedMessage, NewJobMessage} from '../../src/message' | ||
import {CommitHash} from '../../src/commit-hash' | ||
import {JobId} from '../../src/job-id' | ||
|
||
describe('Message', () => { | ||
it('should have a payload', () => { | ||
const message = new NewJobMessage('payload', 0) | ||
const message = new NewJobMessage('payload', new JobId(0)) | ||
expect(message.getPayload()).toBe('payload') | ||
}) | ||
|
||
it('could have an optional reference (commit hash) to another job', () => { | ||
const hash = new CommitHash('f1a69d48a01cc130a64aeac5eaf762e4ba685de7') | ||
|
||
const message = new JobFinishedMessage('payload', 0, hash) | ||
const message = new JobFinishedMessage('payload', new JobId(0), hash) | ||
|
||
expect(message.getJobRef().equalsTo(hash)).toBe(true) | ||
}) | ||
|
||
it('should allow to omit the job reference', () => { | ||
const message = new NewJobMessage('payload', 0) | ||
const message = new NewJobMessage('payload', new JobId(0)) | ||
|
||
expect(message.getJobRef().isNull()).toBe(true) | ||
}) | ||
|
||
it('should indicate if it has a job ref', () => { | ||
const messageWithoutJobRef = new NewJobMessage('payload', 0) | ||
const messageWithoutJobRef = new NewJobMessage('payload', new JobId(0)) | ||
expect(messageWithoutJobRef.hasJobRef()).toBe(false) | ||
|
||
const hash = new CommitHash('f1a69d48a01cc130a64aeac5eaf762e4ba685de7') | ||
const messageWithJobRef = new JobFinishedMessage('payload', 0, hash) | ||
const messageWithJobRef = new JobFinishedMessage( | ||
'payload', | ||
new JobId(0), | ||
hash | ||
) | ||
expect(messageWithJobRef.hasJobRef()).toBe(true) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.