Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbarbara committed Oct 28, 2023
1 parent ede049f commit 6d10706
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
3 changes: 0 additions & 3 deletions test/tours/__snapshots__/no-dom.spec.tsx.snap

This file was deleted.

3 changes: 3 additions & 0 deletions test/tours/__snapshots__/ssr.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Joyride > SSR should render without errors 1`] = `"<div data-test-id="demo"><main><div class="hero"><div class="container"><div class="hero__content"><h1><span>Create walkthroughs and guided tours for your ReactJS apps.</span></h1><button data-test-id="start" type="button">Let&#x27;s Go!</button></div></div></div><div class="demo__section projects"><div class="container"><h2><span>Projects</span></h2><div class="list"><div>Installation</div><div>Documentation</div><div>Support </div></div></div></div><div class="demo__section mission"><div class="container"><h2><span>Mission</span></h2><button data-test-id="mission-button" type="button">Click me</button></div></div><div class="demo__section about"><div class="container"><h2><span>About</span></h2></div></div></main><footer class="demo__footer"><div class="container"><button type="button">Joyride</button></div></footer></div>"`;
27 changes: 19 additions & 8 deletions test/tours/no-dom.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
/**
* @jest-environment node
*/

import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';

import Standard from '../__fixtures__/Standard';
import { fireEvent, render, screen } from '../__fixtures__/test-utils';

const mockCallback = jest.fn();

jest.mock('~/modules/dom', () => {
const originalModule = jest.requireActual('~/modules/dom');

return {
...originalModule,
canUseDOM: jest.fn().mockImplementation(() => false),
};
});

describe('Joyride > NO-DOM', () => {
it('should render without errors', async () => {
const view = renderToStaticMarkup(<Standard />);
render(<Standard callback={mockCallback} />);

it('should not render the step when starting the tour', async () => {
fireEvent.click(screen.getByTestId('start'));

expect(screen.queryById('react-joyride-step-0')).not.toBeInTheDocument();

expect(view).toMatchSnapshot();
expect(mockCallback).not.toHaveBeenCalled();
});
});
16 changes: 16 additions & 0 deletions test/tours/ssr.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @jest-environment node
*/

import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';

import Standard from '../__fixtures__/Standard';

describe('Joyride > SSR', () => {
it('should render without errors', async () => {
const view = renderToStaticMarkup(<Standard />);

expect(view).toMatchSnapshot();
});
});

0 comments on commit 6d10706

Please sign in to comment.