storybook/addons/viewport/src/components/tests/SelectViewport.test.js
Norbert de Langen a270216e96 Merge branch 'master' into release/3.3
# Conflicts:
#	CONTRIBUTING.md
#	addons/actions/package.json
#	addons/comments/package.json
#	addons/events/package.json
#	addons/info/package.json
#	addons/knobs/package.json
#	addons/links/package.json
#	addons/notes/package.json
#	addons/storyshots/package.json
#	app/react-native/package.json
#	app/react/package.json
#	app/vue/package.json
#	dependencies.yml
#	examples/cra-kitchen-sink/package.json
#	examples/cra-kitchen-sink/src/stories/__snapshots__/index.storyshot
#	examples/crna-kitchen-sink/package.json
#	examples/react-native-vanilla/package.json
#	lib/ui/package.json
#	lib/ui/src/modules/ui/components/stories_panel/stories_tree/index.test.js
#	yarn.lock
2017-09-30 23:19:44 +02:00

54 lines
1.4 KiB
JavaScript

import React from 'react';
import { shallow } from 'enzyme'; // eslint-disable-line import/no-extraneous-dependencies
import { SelectViewport } from '../SelectViewport';
import { viewports, defaultViewport } from '../viewportInfo';
import * as styles from '../styles';
describe('Viewport/SelectViewport', () => {
let subject;
let props;
beforeEach(() => {
props = {
onChange: jest.fn(),
activeViewport: defaultViewport,
};
subject = shallow(<SelectViewport {...props} />);
});
describe('label', () => {
let label;
beforeEach(() => {
label = subject.find('label');
});
it('is correctly styled', () => {
expect(label.props().style).toEqual(styles.label);
});
});
describe('select', () => {
it('has a default option first', () => {
const firstOption = subject.find('option').first();
expect(firstOption.props().value).toEqual(defaultViewport);
});
describe('dynamic options', () => {
const viewportKeys = Object.keys(viewports);
it('has at least 1 option', () => {
expect(viewportKeys.length).toBeGreaterThan(0);
});
viewportKeys.forEach(key => {
let option;
it(`renders an option for ${viewports[key].name}`, () => {
option = subject.find(`[value="${key}"]`);
expect(option.text()).toEqual(viewports[key].name);
});
});
});
});
});