Skip to content

Instantly share code, notes, and snippets.

@janhesters
Created September 26, 2020 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janhesters/90b102c8d4a8865e288bdbeccc3259e1 to your computer and use it in GitHub Desktop.
Save janhesters/90b102c8d4a8865e288bdbeccc3259e1 to your computer and use it in GitHub Desktop.
Tests for home page component.
import React from 'react';
import { describe } from 'riteway';
import render from 'riteway/render-component.js';
import HomePage from './home-page-component.js';
const createProps = ({ count = 0 } = {}) => ({ count });
describe('HomePage component', async assert => {
const createHomePage = (props = {}) => render(<HomePage {...props} />);
{
const props = createProps();
const $ = createHomePage(props);
assert({
given: 'a count',
should: 'render the count',
actual: $('.count').text(),
expected: props.count.toString(),
});
}
{
const props = createProps({ count: 5 });
const $ = createHomePage(props);
assert({
given: 'a count',
should: 'render the count',
actual: $('.count').text(),
expected: props.count.toString(),
});
}
{
const props = createProps();
const $ = createHomePage(props);
assert({
given: 'just rendering',
should: 'render the increment button',
actual: $('.increment-button').length,
expected: 1,
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment