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


TypeScript redux-mock-store.default函數代碼示例

本文整理匯總了TypeScript中redux-mock-store.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: configureMockStore

import configureMockStore from 'redux-mock-store';
import { PlaylistSrv } from '../playlist_srv';
import { setStore } from 'app/store/store';

const mockStore = configureMockStore();

setStore(
  mockStore({
    location: {},
  })
);

const dashboards = [{ url: 'dash1' }, { url: 'dash2' }];

const createPlaylistSrv = (): [PlaylistSrv, { url: jest.MockInstance<any, any> }] => {
  const mockBackendSrv = {
    get: jest.fn(url => {
      switch (url) {
        case '/api/playlists/1':
          return Promise.resolve({ interval: '1s' });
        case '/api/playlists/1/dashboards':
          return Promise.resolve(dashboards);
        default:
          throw new Error(`Unexpected url=${url}`);
      }
    }),
  };

  const mockLocation = {
    url: jest.fn(),
    search: () => ({}),
開發者ID:bergquist,項目名稱:grafana,代碼行數:31,代碼來源:playlist_srv.test.ts

示例2: it

  it('should interleave actions emitted in the middle of queue', () => {
    const delta1 = sinon.spy(action$ =>
      action$
        .thru(ofType('FIRST_REQUEST'))
        .map(() => ({ type: 'SECOND_REQUEST' }))
    );
    const delta2 = sinon.spy(action$ =>
      Kefir.merge([
        action$
          .thru(ofType('FIRST_REQUEST'))
          .map(() => ({ type: 'FIRST_RESPONSE' })),
        action$
          .thru(ofType('SECOND_REQUEST'))
          .map(() => ({ type: 'SECOND_RESPONSE' }))
      ])
    );
    const store = configureStore([observeDelta(delta1, delta2)])({});
    const [action$] = delta2.args[0];

    expect(action$).to.emit(
      [
        value({ type: 'FIRST_REQUEST' }),
        value({ type: 'SECOND_REQUEST' }),
        value({ type: 'SECOND_RESPONSE' }),
        value({ type: 'FIRST_RESPONSE' })
      ],
      () => {
        store.dispatch({ type: 'FIRST_REQUEST' });
      }
    );
  });
開發者ID:valtech-nyc,項目名稱:brookjs,代碼行數:31,代碼來源:observeDelta.spec.ts

示例3: it

describe('Trainer Module: fetchTrainingList action', () => {
  const createStore = configureStore<TrainingState>([thunk]);

  it('should be a function', () => {
    // Assert
    expect(fetchTrainingList).to.be.a('function');
  });

  it('should dispatch a GET_SUMMARY_TRAINING_REQUEST_COMPLETED action with the fetched training list',
    sinon.test(function(done) {
      // Arrange
      const sinon: sinon.SinonStatic = this;
      const trainerId = '123';
      const trainings: TrainingSummary[] = [
        {
          id: '32',
          name: 'React/Redux',
          isActive: true,
          start: new Date(),
          end: new Date(),
        },
        {
          id: '12',
          name: 'Responsive web design',
          isActive: true,
          start: new Date(),
          end: new Date(),
        },
        {
          id: '33',
          name: 'AngularJS 2.0',
          isActive: true,
          start: new Date(),
          end: new Date(),
        },
      ];

      const getTrainingListByTrainer = sinon.stub(trainingApi, 'getTrainingListByTrainer')
        .returns({
          then: (callback) => {
            callback(trainings);
          },
        });
      const expectedAction = {
        type: trainerActionEnums.GET_SUMMARY_TRAINING_REQUEST_COMPLETED,
        payload: trainings,
      };

      // Act
      const store = createStore(new TrainingState());
      store.dispatch(fetchTrainingList(trainerId))
        .then(() => {
          // Assert
          const action = store.getActions().shift();
          expect(action).to.be.deep.equals(expectedAction);
          done();
        }).catch(done);
    }));
});
開發者ID:MasterLemon2016,項目名稱:LeanMood,代碼行數:59,代碼來源:training.spec.ts

示例4: beforeEach

 beforeEach(() => {
   const mockStore = configureStore([thunk, promiseMiddleware()]);
   store = mockStore({});
   axios.get = sinon.stub().returns(Promise.resolve(resolvedObject));
   axios.post = sinon.stub().returns(Promise.resolve(resolvedObject));
   axios.put = sinon.stub().returns(Promise.resolve(resolvedObject));
   axios.delete = sinon.stub().returns(Promise.resolve(resolvedObject));
 });
開發者ID:gjik911,項目名稱:git_01,代碼行數:8,代碼來源:flock-relation-reducer.spec.ts

示例5: createMockStore

export function createMockStore(state: IApplicationState): any {
  const sagaMiddleware = createSagaMiddleware()

  const middlewares = [
    sagaMiddleware,
  ]

  const mockStore = configureStore(middlewares)
  const store = mockStore(state)

  sagaMiddleware.run(rootSaga)

  return store
}
開發者ID:goblindegook,項目名稱:dictionary-react-redux-typescript,代碼行數:14,代碼來源:createMockStore.ts

示例6: configureStore

import configureStore from 'redux-mock-store';
import reduxThunk from 'redux-thunk';
import * as apiMember from '../../../api/member';
import { fetchMembers } from './fetchMembers';

const middlewares = [reduxThunk];
const getMockStore = configureStore(middlewares);

describe('members/list/actions/fetchMembers tests', () => {
    
         it('should call to apiMember.fetchMembers', (done) => {
        // Arrange
            const fetchMembersStub = jest.spyOn(apiMember.memberAPI, 'fetchMembers');

        // Act
            const store = getMockStore();
             store.dispatch<any>(fetchMembers())
                    .then(() => {
                // Assert
                        expect(fetchMembersStub).toHaveBeenCalled();
                        done();
                        });
        });
    });
開發者ID:Lemoncode,項目名稱:react-typescript-samples,代碼行數:24,代碼來源:fetchMembers.spec.ts

示例7: configureStore

import ReduxThunk from 'redux-thunk';
import configureStore from 'redux-mock-store';

import {trainerActionEnums} from '../../../../../../common/actionEnums/trainer';
import {trainerApi} from '../../../../../../rest-api/';
import {fetchTrainingContentCompleted, fetchTrainingContentStarted} from '../fetchTrainingContent';

const middlewares = [ReduxThunk];
const mockStore = configureStore(middlewares);

describe('trainingConentRequestCompleted', () => {
  it('is defined', () => {
    // Assert
    expect(fetchTrainingContentCompleted).not.to.be.undefined;
  });

  it('returns expected type GET_TRAINING_CONTENT_REQUEST_COMPLETED', () => {
    // Assert
    expect(fetchTrainingContentCompleted(null).type).to
      .equal(trainerActionEnums.GET_TRAINING_CONTENT_REQUEST_COMPLETED);
  });

  it('returns expected payload equals "Test content"', () => {
    // Arrange
    const expectedTrainingContent = 'Test content';

    // Act
    const actionResult = fetchTrainingContentCompleted(expectedTrainingContent);

    // Assert
    expect(actionResult.payload).to.equal(expectedTrainingContent);
開發者ID:MasterLemon2016,項目名稱:LeanMood,代碼行數:31,代碼來源:fetchTrainingContent.spec.ts

示例8: beforeEach

 beforeEach(() => {
   const mockStore = configureStore([thunk, promiseMiddleware()]);
   store = mockStore({ authentication: { account: { langKey: 'en' } } });
 });
開發者ID:gjik911,項目名稱:git_01,代碼行數:4,代碼來源:authentication.spec.ts


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