kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Tests: mock staticClient correctly
rodzic
ea26e86a94
commit
6e27116aa4
|
@ -1,6 +1,7 @@
|
|||
/node_modules/**
|
||||
/static/**
|
||||
/static-test/**
|
||||
/public/**
|
||||
/tmp/**
|
||||
/coverage/**
|
||||
!.eslintrc.js
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import MockAdapter from 'axios-mock-adapter';
|
||||
|
||||
const api = jest.requireActual('../api').default;
|
||||
const api = jest.requireActual('../api');
|
||||
let mocks = [];
|
||||
|
||||
export const __stub = func => mocks.push(func);
|
||||
|
@ -11,8 +11,10 @@ const setupMock = axios => {
|
|||
mocks.map(func => func(mock));
|
||||
};
|
||||
|
||||
export const staticClient = api.staticClient;
|
||||
|
||||
export default (...params) => {
|
||||
const axios = api(...params);
|
||||
const axios = api.default(...params);
|
||||
setupMock(axios);
|
||||
return axios;
|
||||
};
|
||||
|
|
|
@ -5,15 +5,17 @@ import {
|
|||
fetchAboutPage,
|
||||
} from '../about';
|
||||
import { Map as ImmutableMap } from 'immutable';
|
||||
import { __stub as stubApi } from 'soapbox/api';
|
||||
import MockAdapter from 'axios-mock-adapter';
|
||||
import { staticClient } from 'soapbox/api';
|
||||
import { mockStore } from 'soapbox/test_helpers';
|
||||
|
||||
describe('fetchAboutPage()', () => {
|
||||
it('creates the expected actions on success', () => {
|
||||
|
||||
stubApi(mock => {
|
||||
mock.onGet('/instance/about/index.html').reply(200, '<h1>Hello world</h1>');
|
||||
});
|
||||
const mock = new MockAdapter(staticClient);
|
||||
|
||||
mock.onGet('/instance/about/index.html')
|
||||
.reply(200, '<h1>Hello world</h1>');
|
||||
|
||||
const expectedActions = [
|
||||
{ type: FETCH_ABOUT_PAGE_REQUEST, slug: 'index' },
|
||||
|
|
Ładowanie…
Reference in New Issue