mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 19:01:05 +08:00
# 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
54 lines
1.4 KiB
JavaScript
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);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|