Implemented dependency injection in all tag related components

This commit is contained in:
Alejandro Celaya
2018-12-18 11:28:15 +01:00
parent 79a0a5e4ea
commit 471322f4db
13 changed files with 75 additions and 81 deletions

View File

@@ -3,12 +3,12 @@ import { shallow } from 'enzyme';
import sinon from 'sinon';
import searchBarCreator from '../../src/short-urls/SearchBar';
import SearchField from '../../src/utils/SearchField';
import Tag from '../../src/tags/helpers/Tag';
describe('<SearchBar />', () => {
let wrapper;
const listShortUrlsMock = sinon.spy();
const Tag = () => '';
const SearchBar = searchBarCreator(Tag);
const SearchBar = searchBarCreator({});
afterEach(() => {
listShortUrlsMock.resetHistory();

View File

@@ -1,13 +1,15 @@
import React from 'react';
import { shallow } from 'enzyme';
import { Link } from 'react-router-dom';
import TagCard from '../../src/tags/TagCard';
import createTagCard from '../../src/tags/TagCard';
import TagBullet from '../../src/tags/helpers/TagBullet';
describe('<TagCard />', () => {
let wrapper;
beforeEach(() => {
const TagCard = createTagCard(() => '', () => '', {});
wrapper = shallow(<TagCard tag="ssr" currentServerId="1" />);
});
afterEach(() => wrapper.unmount());

View File

@@ -2,16 +2,17 @@ import React from 'react';
import { shallow } from 'enzyme';
import { identity, range } from 'ramda';
import * as sinon from 'sinon';
import TagsList from '../../src/tags/TagsList';
import createTagsList from '../../src/tags/TagsList';
import MuttedMessage from '../../src/utils/MuttedMessage';
import TagCard from '../../src/tags/TagCard';
import SearchField from '../../src/utils/SearchField';
describe('<TagsList />', () => {
let wrapper;
const filterTags = sinon.spy();
const TagCard = () => '';
const createWrapper = (tagsList) => {
const params = { serverId: '1' };
const TagsList = createTagsList(TagCard);
wrapper = shallow(
<TagsList forceListTags={identity} filterTags={filterTags} match={{ params }} tagsList={tagsList} />