test.js.hbs 1.29 KB
Newer Older
dengxiaofeng's avatar
dengxiaofeng committed
1
/**
邓晓峰's avatar
邓晓峰 committed
2 3 4 5 6
*
* Tests for {{ properCase name }}
*
*
*/
dengxiaofeng's avatar
dengxiaofeng committed
7 8 9 10 11 12 13 14 15 16 17 18 19

import React from 'react';
import { render } from 'react-testing-library';
{{#if wantMessages}}
import { IntlProvider } from 'react-intl';
{{/if}}
// import 'jest-dom/extend-expect'; // add some helpful assertions

import {{ properCase name }} from '../index';
{{#if wantMessages}}
import { DEFAULT_LOCALE } from '../../../i18n';
{{/if}}

邓晓峰's avatar
邓晓峰 committed
20 21
describe('
<{{ properCase name }} />', () => {
22 23
  it('Expect to not log errors in console', () => {
  const spy = jest.spyOn(global.console, 'error');
dengxiaofeng's avatar
dengxiaofeng committed
24
{{#if wantMessages}}
邓晓峰's avatar
邓晓峰 committed
25 26 27 28 29
render(
<IntlProvider locale={DEFAULT_LOCALE}>
  <{{ properCase name }} />
</IntlProvider>,
);
dengxiaofeng's avatar
dengxiaofeng committed
30
{{else}}
邓晓峰's avatar
邓晓峰 committed
31 32
render(
<{{ properCase name }} />);
dengxiaofeng's avatar
dengxiaofeng committed
33
{{/if}}
34
  expect(spy).not.toHaveBeenCalled();
邓晓峰's avatar
邓晓峰 committed
35
});
dengxiaofeng's avatar
dengxiaofeng committed
36

邓晓峰's avatar
邓晓峰 committed
37
it('Expect to have additional unit tests specified', () => {
38
  expect(true).toEqual(false);
邓晓峰's avatar
邓晓峰 committed
39
});
dengxiaofeng's avatar
dengxiaofeng committed
40

邓晓峰's avatar
邓晓峰 committed
41 42 43 44 45 46
/**
* Unskip this test to use it
*
* @see {@link https://jestjs.io/docs/en/api#testskipname-fn}
*/
it.skip('Should render and match the snapshot', () => {
dengxiaofeng's avatar
dengxiaofeng committed
47
{{#if wantMessages}}
48 49 50 51
  const { container: { firstChild },} = render(
    <IntlProvider locale={DEFAULT_LOCALE}>
      <{{ properCase name }} />
    </IntlProvider>,);
dengxiaofeng's avatar
dengxiaofeng committed
52
{{else}}
53 54
  const { container: { firstChild }, } = render(
    <{{ properCase name }} />);
dengxiaofeng's avatar
dengxiaofeng committed
55
{{/if}}
56 57
    expect(firstChild).toMatchSnapshot();
  });
邓晓峰's avatar
邓晓峰 committed
58
});