Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('exitOnEsc: true - ESC cancels the tour', async() => {
const tour = new Tour();
const step = new Step(tour, {});
const stepCancelSpy = spy(step, 'cancel');
const { container } = render(ShepherdElement, {
props: {
step
}
});
fireEvent.keyDown(container.querySelector('.shepherd-element'), { keyCode: 27 });
expect(stepCancelSpy.called).toBe(true);
});
async function renderAndWait(component, options) {
const renderedComponent = render(component, options);
await wait();
return renderedComponent;
}
it('is enabled when false', () => {
const config = {
disabled: false
};
const { container } = render(ShepherdButton, {
props: {
config
}
});
const button = container.querySelector('.shepherd-button');
expect(button.disabled).toBeFalsy();
});
it('Should render greeting', () => {
const { container } = render(MyAwesomeComponent, {
props: { name: 'world' },
});
expect(container.querySelector('h1')).toHaveTextContent('Hello world!');
});
});
it('renders buttons for each item passed to `options.buttons`', () => {
const step = {
options: {
buttons: [
defaultButtons.cancel,
defaultButtons.next
]
}
};
const { container } = render(ShepherdFooter, {
props: {
step
}
});
const buttons = container.querySelectorAll('.shepherd-footer .shepherd-button');
expect(buttons.length).toBe(2);
const cancelButton = container.querySelector('footer .cancel-button');
expect(cancelButton).toHaveAttribute('tabindex', '0');
expect(cancelButton).toHaveClass('shepherd-button-secondary cancel-button shepherd-button');
expect(cancelButton).toHaveTextContent('Exit');
const nextButton = container.querySelector('footer .next-button');
expect(nextButton).toHaveAttribute('tabindex', '0');
expect(nextButton).toHaveClass('shepherd-button-primary next-button shepherd-button');
test("renders nothing", () => {
const getById = queryByAttribute.bind(null, "id");
const dom = render(App);
expect(getById(dom.container, "app")).toBeNull();
});
test("renders the not found message", () => {
const { getByText } = render(NotFound);
expect(getByText("Oops! The page you are looking for doesn't exist.")).toBeTruthy();
});
test("renders the welcome message", () => {
const { getByText } = render(Home);
expect(getByText("An opinionated productive web framework that helps scaling business easier.")).toBeTruthy();
});
it('fetches links asynchronously', (next) => {
const { container } = render(FetchExample)
setTimeout(() => {
expect(container.getElementsByTagName('li').length).toBe(2)
expect(container).toMatchSnapshot()
next()
}, 10)
});
});
it('should render the app', () => {
const { container, getAllByText } = render(App)
expect(container.getElementsByClassName('layout').length).toBe(1)
expect(container.getElementsByClassName('image-content').length).toBe(1)
expect(container.getElementsByClassName('bg-image').length).toBe(1)
expect(container.getElementsByClassName('title').length).toBe(1)
expect(container.getElementsByClassName('title__top').length).toBe(1)
expect(container.getElementsByClassName('title__back').length).toBe(1)
expect(container.getElementsByClassName('title__front').length).toBe(1)
expect(getAllByText('Hello').length).toBe(1)
expect(getAllByText('World').length).toBe(2)
expect(container).toMatchSnapshot()
})
})