当前位置: 首页>>代码示例>>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;未经允许,请勿转载。