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