Skip to content

Commit

Permalink
feat: update test snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
heiyu4585 committed Dec 14, 2022
1 parent 74f3283 commit 7b7fac8
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 17 deletions.
200 changes: 200 additions & 0 deletions components/tour/__tests__/__snapshots__/index.test.tsx.snap
Expand Up @@ -31,6 +31,12 @@ exports[`Tour basic 1`] = `
</div>
`;

exports[`Tour button props onClick 1`] = `
<div
style="position: absolute; top: 0px; left: 0px; width: 100%;"
/>
`;

exports[`Tour rtl render component should be rendered correctly in RTL direction 1`] = `null`;

exports[`Tour single 1`] = `
Expand All @@ -42,6 +48,200 @@ exports[`Tour single 1`] = `
</button>
`;

exports[`Tour step support Primary 1`] = `
<body>
<div
style="position: absolute; top: 0px; left: 0px; width: 100%;"
/>
<div
style="position: absolute; top: 0px; left: 0px; width: 100%;"
/>
<div
style="position: absolute; top: 0px; left: 0px; width: 100%;"
/>
<div
style="position: absolute; top: 0px; left: 0px; width: 100%;"
/>
<div>
<button
disabled=""
type="button"
>
Cover
</button>
<div>
<div
class="ant-tour"
style="z-index: 1090; opacity: 0;"
>
<div
class="ant-tour-primary ant-tour-content"
>
<div
class="ant-tour-arrow"
/>
<div
class="ant-tour-inner"
>
<span
aria-label="close"
class="anticon anticon-close ant-tour-close"
role="img"
tabindex="-1"
>
<svg
aria-hidden="true"
data-icon="close"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"
/>
</svg>
</span>
<div
class="ant-tour-header"
>
<div
class="ant-tour-title"
>
primary title
</div>
</div>
<div
class="ant-tour-description"
>
primary description.
</div>
<div
class="ant-tour-footer"
>
<div
class="ant-tour-sliders"
>
<span
class="ant-tour-slider"
/>
<span
class="ant-tour-slider-active ant-tour-slider"
/>
</div>
<div
class="ant-tour-buttons"
>
<button
class="ant-btn ant-btn-default ant-btn-sm ant-btn-background-ghost ant-tour-prev-btn"
type="button"
>
<span>
Previous
</span>
</button>
<button
ant-click-animating-without-extra-node="false"
class="ant-btn ant-btn-default ant-btn-sm ant-tour-next-btn"
type="button"
>
<span>
Finish
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div
class="ant-tour-target-placeholder"
style="left: -6px; top: -6px; width: 12px; height: 12px; position: fixed; pointer-events: none;"
/>
</div>
<div>
<div
class="ant-tour-mask"
style="position: fixed; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 900; pointer-events: none;"
>
<svg
style="width: 100%; height: 100%;"
>
<defs>
<mask
id="ant-tour-mask-test-id"
>
<rect
fill="white"
height="100%"
width="100%"
x="0"
y="0"
/>
<rect
class="ant-tour-placeholder-animated"
fill="black"
height="12"
rx="2"
width="12"
x="-6"
y="-6"
/>
</mask>
</defs>
<rect
fill="rgba(0,0,0,0.5)"
height="100%"
mask="url(#ant-tour-mask-test-id)"
width="100%"
x="0"
y="0"
/>
<rect
fill="transparent"
height="-6"
pointer-events="auto"
width="100%"
x="0"
y="0"
/>
<rect
fill="transparent"
height="100%"
pointer-events="auto"
width="-6"
x="0"
y="0"
/>
<rect
fill="transparent"
height="calc(100vh - 6px)"
pointer-events="auto"
width="100%"
x="0"
y="6"
/>
<rect
fill="transparent"
height="100%"
pointer-events="auto"
width="calc(100vw - 6px)"
x="6"
y="0"
/>
</svg>
</div>
</div>
<div
style="position: absolute; top: 0px; left: 0px; width: 100%;"
/>
</body>
`;

exports[`Tour steps is empty 1`] = `
<button
disabled=""
Expand Down
36 changes: 19 additions & 17 deletions components/tour/__tests__/index.test.tsx
Expand Up @@ -29,10 +29,10 @@ describe('Tour', () => {
</>
);
};
const { getByText, container } = render(<App />);
const { getByText, baseElement } = render(<App />);
expect(getByText('cover title')).toBeTruthy();
expect(getByText('cover description.')).toBeTruthy();
expect(container.firstChild).toMatchSnapshot();
expect(baseElement).toMatchSnapshot();
});

it('steps is empty', () => {
Expand All @@ -48,8 +48,8 @@ describe('Tour', () => {
</>
);
};
const { container } = render(<App />);
expect(container.firstChild).toMatchSnapshot();
const { baseElement } = render(<App />);
expect(baseElement).toMatchSnapshot();
});

it('steps props stepRender', () => {
Expand Down Expand Up @@ -95,14 +95,14 @@ describe('Tour', () => {
</>
);
};
const { container } = render(<App />);
const { baseElement } = render(<App />);
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
fireEvent.click(screen.getByRole('button', { name: 'Previous' }));
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
fireEvent.click(screen.getByRole('button', { name: 'Finish' }));
expect(onClickMock).toHaveBeenCalledTimes(5);
expect(container.firstChild).toMatchSnapshot();
expect(baseElement).toMatchSnapshot();
});

it('button props onClick', () => {
Expand Down Expand Up @@ -141,15 +141,16 @@ describe('Tour', () => {
</>
);
};
const { container } = render(<App />);
expect(container.querySelector('#btnName')).toHaveTextContent('defaultBtn');
const { baseElement } = render(<App />);
expect(baseElement.querySelector('#btnName')).toHaveTextContent('defaultBtn');
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
expect(container.querySelector('#btnName')).toHaveTextContent('nextButton');
expect(baseElement.querySelector('#btnName')).toHaveTextContent('nextButton');
fireEvent.click(screen.getByRole('button', { name: 'Previous' }));
expect(container.querySelector('#btnName')).toHaveTextContent('prevButton');
expect(baseElement.querySelector('#btnName')).toHaveTextContent('prevButton');
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
fireEvent.click(screen.getByRole('button', { name: 'Finish' }));
expect(container.querySelector('#btnName')).toHaveTextContent('finishButton');
expect(baseElement.querySelector('#btnName')).toHaveTextContent('finishButton');
expect(baseElement).toMatchSnapshot();
});

it('Primary', () => {
Expand All @@ -174,10 +175,10 @@ describe('Tour', () => {
</>
);
};
const { getByText, container } = render(<App />);
const { getByText, baseElement } = render(<App />);
expect(getByText('primary description.')).toBeTruthy();
expect(container.querySelector('.ant-tour-content')).toHaveClass('ant-tour-primary');
expect(container.firstChild).toMatchSnapshot();
expect(baseElement.querySelector('.ant-tour-content')).toHaveClass('ant-tour-primary');
expect(baseElement).toMatchSnapshot();
});

it('step support Primary', () => {
Expand Down Expand Up @@ -208,12 +209,13 @@ describe('Tour', () => {
</>
);
};
const { getByText, container } = render(<App />);
const { getByText, container, baseElement } = render(<App />);
expect(getByText('cover description.')).toBeTruthy();
expect(container.querySelector('.ant-tour-content.ant-tour-primary')).toBeFalsy();
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
expect(getByText('primary description.')).toBeTruthy();
expect(container.querySelector('.ant-tour-content.ant-tour-primary')).toBeTruthy();
expect(baseElement).toMatchSnapshot();
});

it('basic', () => {
Expand Down Expand Up @@ -279,7 +281,7 @@ describe('Tour', () => {
</>
);
};
const { getByText, container } = render(<App />);
const { getByText, container, baseElement } = render(<App />);
fireEvent.click(screen.getByRole('button', { name: 'Show' }));
expect(getByText('Show in Center')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
Expand All @@ -288,7 +290,7 @@ describe('Tour', () => {
expect(getByText('Adjust Placement')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Finish' }));
expect(container.querySelector('.ant-tour')).toBeFalsy();
expect(container.firstChild).toMatchSnapshot();
expect(baseElement).toMatchSnapshot();
});
it('panelRender should correct render when total is undefined', () => {
expect(() => {
Expand Down

0 comments on commit 7b7fac8

Please sign in to comment.