Skip to content

Commit

Permalink
Test: Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Sapegin committed Oct 18, 2018
1 parent ffd8adb commit dc6f718
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 41 deletions.
4 changes: 2 additions & 2 deletions loaders/utils/__tests__/__snapshots__/getProps.spec.js.snap
Expand Up @@ -130,7 +130,7 @@ exports[`should highlight code in description (fenced code block) 1`] = `
Object {
"description": "The only true button.
<span class=\\"hljs-selector-tag\\">alert</span>(<span class=\\"hljs-string\\">'Hello world'</span>);
<span class=\\"hljs-function\\"><span class=\\"hljs-title\\">alert</span>(<span class=\\"hljs-string\\">'Hello world'</span>);</span>
",
"doclets": Object {},
"methods": Array [],
Expand All @@ -142,7 +142,7 @@ exports[`should highlight code in description (regular code block) 1`] = `
Object {
"description": "The only true button.
<span class=\\"hljs-selector-tag\\">alert</span>(<span class=\\"hljs-string\\">'Hello world'</span>);
<span class=\\"hljs-function\\"><span class=\\"hljs-title\\">alert</span>(<span class=\\"hljs-string\\">'Hello world'</span>);</span>
",
"doclets": Object {},
"methods": Array [],
Expand Down
Expand Up @@ -11,7 +11,7 @@ exports[`if a custom href is provided, should use it instead of generating inter
"visibleName": "External example",
},
Object {
"href": "blank#input",
"href": "/#input",
"name": "Input",
"slug": "input",
"visibleName": "Input",
Expand Down Expand Up @@ -70,13 +70,13 @@ exports[`should set a parameter on link when useHashId is activated 1`] = `
items={
Array [
Object {
"href": "blank#/Components?id=button",
"href": "/#/Components?id=button",
"name": "Button",
"slug": "button",
"visibleName": "Button",
},
Object {
"href": "blank#/Components?id=input",
"href": "/#/Components?id=input",
"name": "Input",
"slug": "input",
"visibleName": "Input",
Expand All @@ -92,12 +92,12 @@ exports[`should set a sub route on link when useHashId is deactivated 1`] = `
items={
Array [
Object {
"href": "blank#/Components/Button",
"href": "/#/Components/Button",
"name": "Button",
"slug": "button",
},
Object {
"href": "blank#/Components/Input",
"href": "/#/Components/Input",
"name": "Input",
"slug": "input",
},
Expand All @@ -112,13 +112,13 @@ exports[`should set the correct href for items 1`] = `
items={
Array [
Object {
"href": "blank#button",
"href": "/#button",
"name": "Button",
"slug": "button",
"visibleName": "Button",
},
Object {
"href": "blank#input",
"href": "/#input",
"name": "Input",
"slug": "input",
"visibleName": "Input",
Expand Down
5 changes: 3 additions & 2 deletions src/rsg-components/Preview/Preview.spec.js
Expand Up @@ -30,10 +30,11 @@ afterEach(() => {

it('should unmount Wrapper component', () => {
const actual = mount(<Preview code={code} evalInContext={evalInContext} />, options);
const node = actual.instance().mountNode;

expect(actual.html()).toMatch('<button');
expect(node.innerHTML).toMatch('<button');
actual.unmount();
expect(actual.html()).toBe(null);
expect(node.innerHTML).toBe('');
});

it('should not not fail when Wrapper wasn’t mounted', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/rsg-components/Preview/__snapshots__/Preview.spec.js.snap
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should handle errors 1`] = `
<React.Fragment>
<Fragment>
<div />
<Styled(PlaygroundError)
message="Invariant Violation: Target container is not a DOM element."
/>
</React.Fragment>
</Fragment>
`;

exports[`should handle no code 1`] = `
Expand All @@ -17,9 +17,9 @@ exports[`should handle no code 1`] = `
`;

exports[`should render component renderer 1`] = `
<React.Fragment>
<Fragment>
<div />
</React.Fragment>
</Fragment>
`;

exports[`should update 1`] = `
Expand Down
34 changes: 12 additions & 22 deletions src/rsg-components/SectionHeading/SectionHeading.spec.js
Expand Up @@ -5,7 +5,7 @@ import SectionHeadingRenderer from './SectionHeadingRenderer';
describe('SectionHeading', () => {
const FakeToolbar = () => <div>Fake toolbar</div>;

it('should forward slot properties to the toolbar', () => {
test('should forward slot properties to the toolbar', () => {
const actual = shallow(
<SectionHeading id="section" slotName="slot" slotProps={{ foo: 1, bar: 'baz' }} depth={2}>
A Section
Expand All @@ -15,18 +15,18 @@ describe('SectionHeading', () => {
expect(actual).toMatchSnapshot();
});

it('should render a section heading', () => {
const actual = shallow(
test('render a section heading', () => {
const actual = mount(
<SectionHeadingRenderer id="section" href="/section" depth={2} toolbar={<FakeToolbar />}>
A Section
</SectionHeadingRenderer>
);

expect(actual.dive()).toMatchSnapshot();
expect(actual.find('h2')).toMatchSnapshot();
});

it('should render a deprecated section heading', () => {
const actual = shallow(
test('render a deprecated section heading', () => {
const actual = mount(
<SectionHeadingRenderer
id="section"
href="/section"
Expand All @@ -38,25 +38,20 @@ describe('SectionHeading', () => {
</SectionHeadingRenderer>
);

expect(actual.dive()).toMatchSnapshot();
expect(actual.find('h2')).toMatchSnapshot();
});

it('should prevent the heading level from exceeding the maximum allowed by the Heading component', () => {
const actual = shallow(
test('prevent the heading level from exceeding the maximum allowed by the Heading component', () => {
const actual = mount(
<SectionHeadingRenderer id="section" href="/section" depth={7} toolbar={<FakeToolbar />}>
A Section
</SectionHeadingRenderer>
);

expect(
actual
.dive()
.find('Styled(Heading)')
.prop('level')
).toEqual(6);
expect(actual.find('h6')).toHaveLength(1);
});

it('should the href have a parameter id=section', () => {
test('the href have id=section query parameter ', () => {
const actual = shallow(
<SectionHeading
id="section"
Expand All @@ -69,11 +64,6 @@ describe('SectionHeading', () => {
</SectionHeading>
);

expect(
actual
.dive()
.find('SectionHeadingRenderer')
.prop('href')
).toEqual('blank?id=section');
expect(actual.prop('href')).toEqual('/?id=section');
});
});
@@ -1,9 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SectionHeading render a deprecated section heading 1`] = `
<h2
className="rsg--heading-5 rsg--heading2-7"
id="section"
>
<a
className="rsg--sectionName-2 rsg--isDeprecated-3"
href="/section"
>
A Section
</a>
</h2>
`;

exports[`SectionHeading render a section heading 1`] = `
<h2
className="rsg--heading-5 rsg--heading2-7"
id="section"
>
<a
className="rsg--sectionName-2"
href="/section"
>
A Section
</a>
</h2>
`;

exports[`SectionHeading should forward slot properties to the toolbar 1`] = `
<Styled(SectionHeading)
depth={2}
href="blank#section"
href="/#section"
id="section"
toolbar={
<Slot
Expand Down
Expand Up @@ -2,7 +2,7 @@

exports[`should renderer a link home in isolated mode 1`] = `
<Styled(ToolbarButton)
href="blank#/"
href="/#/"
title="Show all components"
>
<MdFullscreenExit />
Expand All @@ -11,7 +11,7 @@ exports[`should renderer a link home in isolated mode 1`] = `

exports[`should renderer a link to example isolated mode 1`] = `
<Styled(ToolbarButton)
href="blank#!/Pizza/3"
href="/#!/Pizza/3"
title="Open isolated"
>
<MdFullscreen />
Expand All @@ -20,7 +20,7 @@ exports[`should renderer a link to example isolated mode 1`] = `

exports[`should renderer a link to isolated mode 1`] = `
<Styled(ToolbarButton)
href="blank#!/Pizza"
href="/#!/Pizza"
title="Open isolated"
>
<MdFullscreen />
Expand Down

0 comments on commit dc6f718

Please sign in to comment.