-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
564ae51
commit b720d2e
Showing
10 changed files
with
133 additions
and
128 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
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
51 changes: 51 additions & 0 deletions
51
src/goals/ReviewEntries/Redux/tests/ReviewEntriesReducer.test.tsx
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,51 @@ | ||
import { reviewEntriesReducer } from "goals/ReviewEntries/Redux/ReviewEntriesReducer"; | ||
import { | ||
defaultState, | ||
ReviewEntriesActionTypes, | ||
} from "goals/ReviewEntries/Redux/ReviewEntriesReduxTypes"; | ||
import { | ||
ReviewEntriesSense, | ||
ReviewEntriesWord, | ||
} from "goals/ReviewEntries/ReviewEntriesTypes"; | ||
|
||
describe("ReviewEntriesReducer", () => { | ||
it("Returns default state when passed undefined state", () => { | ||
expect(reviewEntriesReducer(undefined, { type: undefined } as any)).toEqual( | ||
defaultState | ||
); | ||
}); | ||
|
||
it("Adds a set of words to a list when passed an UpdateAllWords action", () => { | ||
const revWords = [new ReviewEntriesWord(), new ReviewEntriesWord()]; | ||
const state = reviewEntriesReducer(defaultState, { | ||
type: ReviewEntriesActionTypes.UpdateAllWords, | ||
words: revWords, | ||
}); | ||
expect(state).toEqual({ ...defaultState, words: revWords }); | ||
}); | ||
|
||
it("Updates a specified word when passed an UpdateWord action", () => { | ||
const oldId = "id-of-word-to-be-updated"; | ||
const oldWords: ReviewEntriesWord[] = [ | ||
{ ...new ReviewEntriesWord(), id: "other-id" }, | ||
{ ...new ReviewEntriesWord(), id: oldId, vernacular: "old-vern" }, | ||
]; | ||
const oldState = { ...defaultState, words: oldWords }; | ||
|
||
const newId = "id-after-update"; | ||
const newRevWord: ReviewEntriesWord = { | ||
...new ReviewEntriesWord(), | ||
id: newId, | ||
vernacular: "new-vern", | ||
senses: [{ ...new ReviewEntriesSense(), guid: "new-sense-id" }], | ||
}; | ||
const newWords = [oldWords[0], newRevWord]; | ||
|
||
const newState = reviewEntriesReducer(oldState, { | ||
type: ReviewEntriesActionTypes.UpdateWord, | ||
oldId, | ||
updatedWord: newRevWord, | ||
}); | ||
expect(newState).toEqual({ ...oldState, words: newWords }); | ||
}); | ||
}); |
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
76 changes: 0 additions & 76 deletions
76
src/goals/ReviewEntries/tests/ReviewEntriesReducer.test.tsx
This file was deleted.
Oops, something went wrong.
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.