本文整理汇总了TypeScript中reducers/app.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('allow new priority notification to trump existing ones', () => {
let state = appInitialState;
state = reducer(
state,
openNotification('New notification', {
overwritable: true,
priority: true,
}),
);
// Expect overwritable priority notification to be overwritten
state = reducer(state, openNotification('Second notification'));
expect(state.notifications).toHaveLength(1);
expect(state.notifications[0]).toMatchObject({ message: 'Second notification' });
// Expect priority notification to be inserted at the front of the queue
const pNotif3 = { message: 'Third notification', priority: true };
state = reducer(state, openNotification(pNotif3.message, { priority: pNotif3.priority }));
expect(state.notifications).toHaveLength(2);
expect(state.notifications[0]).toMatchObject(pNotif3);
// Expect new, overwritable, priority notification to be discarded
// if non-overwritable notification is in line
state = reducer(
state,
openNotification('Fourth notification', {
overwritable: true,
priority: true,
}),
);
expect(state.notifications).toHaveLength(2);
expect(state.notifications[0]).toMatchObject(pNotif3);
});
示例2: modifyLesson
test('app should set active lesson', () => {
const anotherLesson: Lesson = lessons[1];
const action: FSA = modifyLesson(anotherLesson);
const nextState: AppState = reducer(appHasActiveLessonState, action);
expect(nextState).toEqual({ ...appInitialState, activeLesson: anotherLesson });
});
示例3: reducer
test('app should subscribe to online status action', () => {
const nextState = reducer(appInitialState, setOnlineStatus(false));
expect(nextState).toHaveProperty('isOnline', false);
expect(reducer(nextState, setOnlineStatus(true))).toHaveProperty('isOnline', true);
});
示例4: changeLesson
test('app should accept lesson change and unset active lesson', () => {
const action: FSA = changeLesson(semester, lesson);
const nextState: AppState = reducer(appInitialState, action);
expect(nextState).toEqual(appInitialState);
});
示例5: selectSemester
test('app should set active semester', () => {
const action: FSA = selectSemester(anotherSemester);
const nextState: AppState = reducer(appInitialState, action);
expect(nextState).toEqual(appHasSemesterTwoState);
});