本文整理汇总了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: () => ({}),
示例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' });
}
);
});
示例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);
}));
});
示例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));
});
示例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
}
示例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();
});
});
});
示例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);
示例8: beforeEach
beforeEach(() => {
const mockStore = configureStore([thunk, promiseMiddleware()]);
store = mockStore({ authentication: { account: { langKey: 'en' } } });
});