本文整理匯總了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);
});