當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript app.default函數代碼示例

本文整理匯總了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);
  });
開發者ID:nusmodifications,項目名稱:nusmods,代碼行數:33,代碼來源:app.test.ts

示例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 });
});
開發者ID:nusmodifications,項目名稱:nusmods,代碼行數:7,代碼來源:app.test.ts

示例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);
});
開發者ID:nusmodifications,項目名稱:nusmods,代碼行數:5,代碼來源:app.test.ts

示例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);
});
開發者ID:nusmodifications,項目名稱:nusmods,代碼行數:6,代碼來源:app.test.ts

示例5: selectSemester

test('app should set active semester', () => {
  const action: FSA = selectSemester(anotherSemester);
  const nextState: AppState = reducer(appInitialState, action);

  expect(nextState).toEqual(appHasSemesterTwoState);
});
開發者ID:nusmodifications,項目名稱:nusmods,代碼行數:6,代碼來源:app.test.ts


注:本文中的reducers/app.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。