mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-23 07:19:50 -04:00
Unit test for UPDATE_CARD_MERGE_STRATEGY reducer
This commit is contained in:
parent
fe2ec7ce52
commit
05500cfbfe
@ -7,48 +7,48 @@ import { CardItem } from '../models/card-state';
|
||||
import { Overlap } from '../common/bible-reference';
|
||||
|
||||
export class AppActionFactory {
|
||||
static newGetSavedPage(pageId: string) {
|
||||
static newGetSavedPage(pageId: string): AppAction {
|
||||
return {
|
||||
type: 'GET_SAVED_PAGE',
|
||||
pageId,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newSavePage(title: string) {
|
||||
static newSavePage(title: string): AppAction {
|
||||
return {
|
||||
type: 'SAVE_PAGE',
|
||||
title,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newUpdateCurrentPage() {
|
||||
static newUpdateCurrentPage(): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_CURRENT_PAGE',
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newUpdateSavedPages(savedPages: IStorable<readonly SavedPage[]>) {
|
||||
static newUpdateSavedPages(savedPages: IStorable<readonly SavedPage[]>): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_SAVED_PAGES',
|
||||
savedPages,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newUpdateSavedPage(savedPage: SavedPage) {
|
||||
static newUpdateSavedPage(savedPage: SavedPage): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_SAVED_PAGE',
|
||||
savedPage,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newRemoveSavedPage(savedPage: SavedPage) {
|
||||
static newRemoveSavedPage(savedPage: SavedPage): AppAction {
|
||||
return {
|
||||
type: 'REMOVE_SAVED_PAGE',
|
||||
savedPage,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newAddCardToSavedPage(card: CardItem, pageId: string) {
|
||||
static newAddCardToSavedPage(card: CardItem, pageId: string): AppAction {
|
||||
return {
|
||||
type: 'ADD_CARD_TO_SAVED_PAGE',
|
||||
card,
|
||||
@ -56,7 +56,7 @@ export class AppActionFactory {
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newAddCard(card: CardItem, nextToItem: CardItem) {
|
||||
static newAddCard(card: CardItem, nextToItem: CardItem): AppAction {
|
||||
return {
|
||||
type: 'ADD_CARD',
|
||||
card,
|
||||
@ -64,7 +64,7 @@ export class AppActionFactory {
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newUpdateCard(newCard: CardItem, oldCard: CardItem) {
|
||||
static newUpdateCard(newCard: CardItem, oldCard: CardItem): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_CARD',
|
||||
newCard,
|
||||
@ -72,14 +72,14 @@ export class AppActionFactory {
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newRemoveCard(card: CardItem) {
|
||||
static newRemoveCard(card: CardItem): AppAction {
|
||||
return {
|
||||
type: 'REMOVE_CARD',
|
||||
card,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newMoveCard(card: CardItem, direction: MoveDirection) {
|
||||
static newMoveCard(card: CardItem, direction: MoveDirection): AppAction {
|
||||
return {
|
||||
type: 'MOVE_CARD',
|
||||
card,
|
||||
@ -87,48 +87,55 @@ export class AppActionFactory {
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newUpdateError(error: Error) {
|
||||
static newUpdateError(error: Error): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_ERROR',
|
||||
error,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newUpdateCardFontSize(cardFontSize: number) {
|
||||
static newUpdateCardMergeStrategy(strategy: Overlap): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_CARD_MERGE_STRATEGY',
|
||||
cardMergeStrategy: strategy,
|
||||
};
|
||||
}
|
||||
|
||||
static newUpdateCardFontSize(cardFontSize: number): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_CARD_FONT_SIZE',
|
||||
cardFontSize,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newUpdateCardFontFamily(cardFontFamily: string) {
|
||||
static newUpdateCardFontFamily(cardFontFamily: string): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_CARD_FONT_FAMILY',
|
||||
cardFontFamily,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newUpdateAutocomplete(words: string[]) {
|
||||
static newUpdateAutocomplete(words: string[]): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_AUTOCOMPLETE',
|
||||
words,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newUpdateDisplaySettings(settings: IStorable<DisplaySettings>) {
|
||||
static newUpdateDisplaySettings(settings: IStorable<DisplaySettings>): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_DISPLAY_SETTINGS',
|
||||
settings,
|
||||
} as AppAction;
|
||||
}
|
||||
static newUser(user: User) {
|
||||
static newUser(user: User): AppAction {
|
||||
return {
|
||||
type: 'SET_USER',
|
||||
user,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newFindNotes(qry: string, nextToItem: CardItem) {
|
||||
static newFindNotes(qry: string, nextToItem: CardItem): AppAction {
|
||||
return {
|
||||
type: 'FIND_NOTES',
|
||||
qry,
|
||||
@ -136,7 +143,7 @@ export class AppActionFactory {
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newGetNote(noteId: string, nextToItem: CardItem) {
|
||||
static newGetNote(noteId: string, nextToItem: CardItem): AppAction {
|
||||
return {
|
||||
type: 'GET_NOTE',
|
||||
noteId,
|
||||
@ -144,21 +151,21 @@ export class AppActionFactory {
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newUpdateNotes(notes: IStorable<readonly NoteItem[]>) {
|
||||
static newUpdateNotes(notes: IStorable<readonly NoteItem[]>): AppAction {
|
||||
return {
|
||||
type: 'UPDATE_NOTES',
|
||||
notes,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newSaveNote(note: NoteItem) {
|
||||
static newSaveNote(note: NoteItem): AppAction {
|
||||
return {
|
||||
type: 'SAVE_NOTE',
|
||||
note,
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newDeleteNote(note: NoteItem) {
|
||||
static newDeleteNote(note: NoteItem): AppAction {
|
||||
return {
|
||||
type: 'DELETE_NOTE',
|
||||
note,
|
||||
|
@ -59,6 +59,14 @@ describe('AppService Reducer', () => {
|
||||
TestBed.configureTestingModule({});
|
||||
});
|
||||
|
||||
it('UPDATE_CARD_MERGE_STRATEGY', () => {
|
||||
for (const strategy of [Overlap.None, Overlap.Equal, Overlap.Subset, Overlap.Intersect]) {
|
||||
const action = AppActionFactory.newUpdateCardMergeStrategy(strategy);
|
||||
const testState = reducer(preState, action);
|
||||
expect(testState.pageSettings.value.mergeStrategy).toEqual(strategy);
|
||||
}
|
||||
});
|
||||
|
||||
it('UPDATE_CARD_FONT_SIZE', () => {
|
||||
const action = AppActionFactory.newUpdateCardFontSize(32);
|
||||
const testState = reducer(preState, action);
|
||||
|
Loading…
x
Reference in New Issue
Block a user