added tests for hostReducer and Header Effects, and switch to typed actions

This commit is contained in:
Art Lowel
2017-01-13 11:25:07 +01:00
parent dba6dcec63
commit 8e4bec9c30
13 changed files with 211 additions and 82 deletions

View File

@@ -1,24 +1,43 @@
import { Action } from "@ngrx/store";
import { type } from "../shared/ngrx/type";
export class HeaderActions {
static COLLAPSE = 'dspace/header/COLLAPSE';
static collapse(): Action {
return {
type: HeaderActions.COLLAPSE
}
}
/**
* For each action type in an action group, make a simple
* enum object for all of this group's action types.
*
* The 'type' utility function coerces strings into string
* literal types and runs a simple check to guarantee all
* action types in the application are unique.
*/
export const HeaderActionTypes = {
COLLAPSE: type('dspace/header/COLLAPSE'),
EXPAND: type('dspace/header/EXPAND'),
TOGGLE: type('dspace/header/TOGGLE')
};
static EXPAND = 'dspace/header/EXPAND';
static expand(): Action {
return {
type: HeaderActions.EXPAND
}
}
export class HeaderCollapseAction implements Action {
type = HeaderActionTypes.COLLAPSE;
static TOGGLE = 'dspace/header/TOGGLE';
static toggle(): Action {
return {
type: HeaderActions.TOGGLE
}
}
constructor() {}
}
export class HeaderExpandAction implements Action {
type = HeaderActionTypes.EXPAND;
constructor() {}
}
export class HeaderToggleAction implements Action {
type = HeaderActionTypes.TOGGLE;
constructor() {}
}
/**
* Export a type alias of all actions in this action group
* so that reducers can easily compose action types
*/
export type HeaderAction
= HeaderCollapseAction
| HeaderExpandAction
| HeaderToggleAction