Skip to content

Commit

Permalink
Only keep one test for smaller reproduction - See facebook/react#20568
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadorequest committed Jan 11, 2021
1 parent a05b6f5 commit 5bf434a
Showing 1 changed file with 81 additions and 81 deletions.
162 changes: 81 additions & 81 deletions src/components/i18n/I18nLink.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,86 +36,86 @@ describe('I18nLink', () => {
expect(link).toMatchSnapshot();
});

test('when using custom CSS class', () => {
const renderer = TestRenderer.create(<I18nLinkTest href={'/'} className="customClassName" />);
const link: any = renderer.toJSON();

expect(link.type).toEqual('a');
expect(link.children).toEqual(['Text']);
expect(link.props.href).toEqual('/en');
expect(link.props.className).toEqual('customClassName');
expect(link).toMatchSnapshot();
});

test('when forcing the locale to use', () => {
const renderer = TestRenderer.create(<I18nLinkTest href={'/'} locale={'fr-FR'} />);
const link: any = renderer.toJSON();

expect(link.type).toEqual('a');
expect(link.children).toEqual(['Text']);
expect(link.props.href).toEqual('/fr-FR');
expect(link).toMatchSnapshot();
});

test('when using wrapChildrenAsLink manually using a <a> element', () => {
const renderer = TestRenderer.create(<I18nLinkTest href={'/'} wrapChildrenAsLink={false} text={<a>Page</a>} />);
const link: any = renderer.toJSON();

expect(link.type).toEqual('a');
expect(link.children).toEqual(['Page']);
expect(link.props.href).toEqual('/en');
expect(link).toMatchSnapshot();
});

test('when using wrapChildrenAsLink manually using a <NavLink> element', () => {
const renderer = TestRenderer.create(<I18nLinkTest href={'/'} wrapChildrenAsLink={false} text={<NavLink>Page</NavLink>} />);
const link: any = renderer.toJSON();

expect(link.type).toEqual('a');
expect(link.children).toEqual(['Page']);
expect(link.props.href).toEqual('/en');
expect(link.props.className).toEqual('nav-link');
expect(link).toMatchSnapshot();
});

test('when using route params', () => {
const renderer = TestRenderer.create(<I18nLinkTest href={'/products/[id]'} params={{ id: 5 }} />);
const link: any = renderer.toJSON();

expect(link.type).toEqual('a');
expect(link.children).toEqual(['Text']);
expect(link.props.href).toEqual('/en/products/5');
expect(link).toMatchSnapshot();
});

test('when using route params and query route params', () => {
const renderer = TestRenderer.create(<I18nLinkTest href={'/products/[id]'} params={{ id: 5 }} query={{ userId: 1 }} />);
const link: any = renderer.toJSON();

expect(link.type).toEqual('a');
expect(link.children).toEqual(['Text']);
expect(link.props.href).toEqual('/en/products/5?userId=1');
expect(link).toMatchSnapshot();
});

test('when using route params and query route params using nested paths', () => {
const renderer = TestRenderer.create(<I18nLinkTest href={'/products/favourites/[id]'} params={{ id: 5 }} query={{ userId: 1 }} />);
const link: any = renderer.toJSON();

expect(link.type).toEqual('a');
expect(link.children).toEqual(['Text']);
expect(link.props.href).toEqual('/en/products/favourites/5?userId=1');
expect(link).toMatchSnapshot();
});

test('when using route params and query route params using nested paths and forcing locale', () => {
const renderer = TestRenderer.create(<I18nLinkTest href={'/products/favourites/[id]'} params={{ id: 5 }} query={{ userId: 1 }} locale={'fr'} />);
const link: any = renderer.toJSON();

expect(link.type).toEqual('a');
expect(link.children).toEqual(['Text']);
expect(link.props.href).toEqual('/fr/products/favourites/5?userId=1');
expect(link).toMatchSnapshot();
});
// test('when using custom CSS class', () => {
// const renderer = TestRenderer.create(<I18nLinkTest href={'/'} className="customClassName" />);
// const link: any = renderer.toJSON();
//
// expect(link.type).toEqual('a');
// expect(link.children).toEqual(['Text']);
// expect(link.props.href).toEqual('/en');
// expect(link.props.className).toEqual('customClassName');
// expect(link).toMatchSnapshot();
// });
//
// test('when forcing the locale to use', () => {
// const renderer = TestRenderer.create(<I18nLinkTest href={'/'} locale={'fr-FR'} />);
// const link: any = renderer.toJSON();
//
// expect(link.type).toEqual('a');
// expect(link.children).toEqual(['Text']);
// expect(link.props.href).toEqual('/fr-FR');
// expect(link).toMatchSnapshot();
// });
//
// test('when using wrapChildrenAsLink manually using a <a> element', () => {
// const renderer = TestRenderer.create(<I18nLinkTest href={'/'} wrapChildrenAsLink={false} text={<a>Page</a>} />);
// const link: any = renderer.toJSON();
//
// expect(link.type).toEqual('a');
// expect(link.children).toEqual(['Page']);
// expect(link.props.href).toEqual('/en');
// expect(link).toMatchSnapshot();
// });
//
// test('when using wrapChildrenAsLink manually using a <NavLink> element', () => {
// const renderer = TestRenderer.create(<I18nLinkTest href={'/'} wrapChildrenAsLink={false} text={<NavLink>Page</NavLink>} />);
// const link: any = renderer.toJSON();
//
// expect(link.type).toEqual('a');
// expect(link.children).toEqual(['Page']);
// expect(link.props.href).toEqual('/en');
// expect(link.props.className).toEqual('nav-link');
// expect(link).toMatchSnapshot();
// });
//
// test('when using route params', () => {
// const renderer = TestRenderer.create(<I18nLinkTest href={'/products/[id]'} params={{ id: 5 }} />);
// const link: any = renderer.toJSON();
//
// expect(link.type).toEqual('a');
// expect(link.children).toEqual(['Text']);
// expect(link.props.href).toEqual('/en/products/5');
// expect(link).toMatchSnapshot();
// });
//
// test('when using route params and query route params', () => {
// const renderer = TestRenderer.create(<I18nLinkTest href={'/products/[id]'} params={{ id: 5 }} query={{ userId: 1 }} />);
// const link: any = renderer.toJSON();
//
// expect(link.type).toEqual('a');
// expect(link.children).toEqual(['Text']);
// expect(link.props.href).toEqual('/en/products/5?userId=1');
// expect(link).toMatchSnapshot();
// });
//
// test('when using route params and query route params using nested paths', () => {
// const renderer = TestRenderer.create(<I18nLinkTest href={'/products/favourites/[id]'} params={{ id: 5 }} query={{ userId: 1 }} />);
// const link: any = renderer.toJSON();
//
// expect(link.type).toEqual('a');
// expect(link.children).toEqual(['Text']);
// expect(link.props.href).toEqual('/en/products/favourites/5?userId=1');
// expect(link).toMatchSnapshot();
// });
//
// test('when using route params and query route params using nested paths and forcing locale', () => {
// const renderer = TestRenderer.create(<I18nLinkTest href={'/products/favourites/[id]'} params={{ id: 5 }} query={{ userId: 1 }} locale={'fr'} />);
// const link: any = renderer.toJSON();
//
// expect(link.type).toEqual('a');
// expect(link.children).toEqual(['Text']);
// expect(link.props.href).toEqual('/fr/products/favourites/5?userId=1');
// expect(link).toMatchSnapshot();
// });
});
});

0 comments on commit 5bf434a

Please sign in to comment.