Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-env mocha */
/* eslint-disable no-console */
import { expect, use } from 'chai';
import Adapter from 'enzyme-adapter-react-16.3';
import { configure, mount } from 'enzyme';
import sinonChai from 'sinon-chai';
import sinon from 'sinon';
import Kefir from 'kefir';
import React from 'react';
import { chaiPlugin } from 'brookjs-desalinate';
import PropTypes from 'prop-types';
import observableOf from '../observableOf';
const { plugin , prop, value, send, error, end } = chaiPlugin({ Kefir });
use(plugin);
configure({ adapter: new Adapter() });
use(sinonChai);
describe('observableOf', () => {
let wrapper;
beforeEach(() => {
sinon.stub(console, 'error');
});
afterEach(() => {
console.error.restore();
wrapper.unmount();
});
it('should not complain if nothing provided', () => {
const NothingProvided = () => <button>Click me</button>;
/* eslint-env mocha */
import Adapter from 'enzyme-adapter-react-16.3';
import { configure, mount } from 'enzyme';
import { expect, use } from 'chai';
import Kefir from 'kefir';
import { chaiPlugin } from 'brookjs-desalinate';
import h from '../h';
import Collector from '../Collector';
import { Provider } from '../context';
const { plugin, value } = chaiPlugin({ Kefir });
configure({ adapter: new Adapter() });
use(plugin);
describe('Collector', () => {
const onButtonClick = e$ => e$.map(() => ({ type: 'CLICK' }));
const CollectedButton = ({ text, enabled, aggregated$ }) => (
{enabled ?
<button>
{text}
</button> :
<span>nothing to click</span>}
);
import React from 'react';
/* eslint-disable import/no-extraneous-dependencies */
import initStoryshots from '@storybook/addon-storyshots';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16.3';
/* eslint-enable */
import MailIcon from './mailIcon';
// Separate the snapshots in directories next to each component
// Name should match with the story name
initStoryshots({
storyKindRegex: /^MailIcon$/
});
configure({ adapter: new Adapter() });
describe(' - with shallow', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow();
});
it('should render a svg composed by 2 path', () => {
expect(wrapper.find('svg[className="mailIcon"]')).toHaveLength(1);
});
});
// @flow
import React from 'react';
/* eslint-disable import/no-extraneous-dependencies */
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16.3';
/* eslint-enable */
import SentimentBarIcon from './sentimentBarIcon';
import type { Props as SentimentBarIconProps } from './sentimentBarIcon';
configure({ adapter: new Adapter() });
describe(' - with shallow', () => {
let wrapper;
let sentimentBarIcon: SentimentBarIconProps;
beforeEach(() => {
sentimentBarIcon = { level: 2 };
wrapper = shallow();
});
it('should render a loading icon', () => {
expect(wrapper.find('svg[className="icon"]')).toHaveLength(1);
});
});
// @flow
import React from 'react';
/* eslint-disable import/no-extraneous-dependencies */
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16.3';
/* eslint-enable */
import TooltipIcon from './tooltipIcon';
configure({ adapter: new Adapter() });
describe(' - with shallow', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow();
});
it('should render a tooltip icon', () => {
expect(wrapper.find('svg[className="icon tooltip"]')).toHaveLength(1);
expect(wrapper.find('text[className="text"]')).toHaveLength(1);
expect(wrapper.find('circle[className="circle"]')).toHaveLength(1);
});
});
import React from 'react';
/* eslint-disable import/no-extraneous-dependencies */
import { configure, shallow } from 'enzyme';
import initStoryshots from '@storybook/addon-storyshots';
import Adapter from 'enzyme-adapter-react-16.3';
/* eslint-enable */
import EditPostIcon from './editPostIcon';
// Separate the snapshots in directories next to each component
// Name should match with the story name
initStoryshots({
storyKindRegex: /^EditPostIcon$/
});
configure({ adapter: new Adapter() });
describe(' - with shallow', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow();
});
it('should render a svg with editPostIcon class', () => {
expect(wrapper.find('svg[className="editPostIcon"]')).toHaveLength(1);
expect(wrapper.find('path')).toHaveLength(1);
});
});
import React from 'react';
/* eslint-disable import/no-extraneous-dependencies */
import initStoryshots from '@storybook/addon-storyshots';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16.3';
/* eslint-enable */
import TickIcon from './tickIcon';
// Separate the snapshots in directories next to each component
// Name should match with the story name
initStoryshots({
storyKindRegex: /^TickIcon$/
});
configure({ adapter: new Adapter() });
describe(' - with shallow', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow();
});
it('should render a svg composed by 2 path', () => {
expect(wrapper.find('svg[className="tickIcon"]')).toHaveLength(1);
});
});
/* eslint-disable import/no-extraneous-dependencies */
import initStoryshots from '@storybook/addon-storyshots';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16.3';
/* eslint-enable */
import Title from './title';
import type { Props as TitleProps } from './title';
import { defaultTitleProps } from './title.stories';
// Separate the snapshots in directories next to each component
// Name should match with the story name
initStoryshots({
storyKindRegex: /^Semantic\s{1}Analysis\|Title$/
});
configure({ adapter: new Adapter() });
describe('<title> - with shallow', () => {
let wrapper;
let title: TitleProps;
beforeEach(() => {
title = { ...defaultTitleProps };
wrapper = shallow(<Title {...title} />);
});
describe('when level is set to 1 (default value) with grey-title1 class', () => {
it('should render a h1', () => {
expect(wrapper.find('h1[className="grey-title1"]').text()).toEqual('My awesome title');
});
});
</title>
/* eslint-disable import/no-extraneous-dependencies */
import initStoryshots from '@storybook/addon-storyshots';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16.3';
/* eslint-enable */
import Checkbox101 from './checkbox101';
import type { Checkbox101Type } from './checkbox101';
// Separate the snapshots in directories next to each component
// Name should match with the story name
initStoryshots({
storyKindRegex: /^Checkbox101$/
});
configure({ adapter: new Adapter() });
const defaultCheckbox: Checkbox101Type = {
onChangeHandler: jest.fn()
};
describe(' - with shallow', () => {
let wrapper: any;
let checkbox: Checkbox101Type;
beforeEach(() => {
checkbox = { ...defaultCheckbox };
wrapper = shallow();
});
it('should render one checkbox with a default label', () => {
const defaultLabel = 'Default';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16.3';
configure({ adapter: new Adapter() });