-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
b0f8921
commit e5242b2
Showing
4 changed files
with
65 additions
and
13 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
28 changes: 18 additions & 10 deletions
28
app/assets/javascripts/mumuki_laboratory/application/submissions-store.js
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,44 @@ | ||
describe("SubmissionsStore", () => { | ||
const emptyProgramSubmission = {"solution[content]": "program {}"}; | ||
/** @type {SubmissionResult} */ | ||
const passedSubmissionResult = {status: 'passed'}; | ||
/** @type {SubmissionAndResult} */ | ||
const passedEmptyProgramSubmissionAndResult = { submission: emptyProgramSubmission, result: passedSubmissionResult }; | ||
|
||
beforeEach(() => { | ||
window.localStorage.clear() | ||
}); | ||
|
||
describe('getLastSubmission', () => { | ||
it("answers null if submission not present", () => { | ||
expect(mumuki.SubmissionsStore.getLastSubmissionAndResult(1)).toBe(null) | ||
}) | ||
|
||
it("answers the last submission result if already sent", () => { | ||
mumuki.SubmissionsStore.setSubmissionResultFor(1, passedEmptyProgramSubmissionAndResult) | ||
expect(mumuki.SubmissionsStore.getLastSubmissionAndResult(1)).toEqual(passedEmptyProgramSubmissionAndResult) | ||
}) | ||
}) | ||
|
||
describe('getLastSubmissionStatus', () => { | ||
it("answers pending if submission not present", () => { | ||
expect(mumuki.SubmissionsStore.getLastSubmissionStatus(1)).toBe('pending') | ||
}) | ||
|
||
it("answers the last submission status if previously sent", () => { | ||
mumuki.SubmissionsStore.setSubmissionResultFor(1, passedEmptyProgramSubmissionAndResult) | ||
expect(mumuki.SubmissionsStore.getLastSubmissionStatus(1)).toBe('passed') | ||
}) | ||
}); | ||
|
||
describe('getCachedResultFor', () => { | ||
it("answers null if submission not present", () => { | ||
expect(mumuki.SubmissionsStore.getSubmissionResultFor(1, emptyProgramSubmission)).toBe(null) | ||
}) | ||
|
||
it("answers the last submission if previously sent", () => { | ||
mumuki.SubmissionsStore.setSubmissionResultFor(1, passedEmptyProgramSubmissionAndResult) | ||
expect(mumuki.SubmissionsStore.getSubmissionResultFor(1, emptyProgramSubmission)).toEqual(passedSubmissionResult) | ||
}) | ||
}); | ||
}) |