[tests][s]: initial tests for components.

This commit is contained in:
anuveyatsu 2020-06-12 16:16:56 +06:00
parent 2f8707a6d4
commit ebfe884b7b
4 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import React from 'react'
import { render } from '@testing-library/react'
import renderer from 'react-test-renderer'
import Item from '../../../components/search/Item'
test('📸 of Item component', () => {
const datapackage = {
name: 'test',
title: 'Title',
description: 'A description.',
organization: {
title: 'test org',
name: 'test-org'
}
}
const tree = renderer.create(<Item datapackage={datapackage} />).toJSON()
expect(tree).toMatchSnapshot()
})

View File

@ -0,0 +1,9 @@
import React from 'react'
import { render } from '@testing-library/react'
import renderer from 'react-test-renderer'
import Total from '../../../components/search/Total'
test('📸 of Total component', () => {
const tree = renderer.create(<Total total={2} />).toJSON()
expect(tree).toMatchSnapshot()
})

View File

@ -0,0 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`📸 of Item component 1`] = `
<div>
<h3
className="text-2xl font-semibold"
>
<a
className="text-primary"
href="/@test-org/test"
onClick={[Function]}
onMouseEnter={[Function]}
>
Title
</a>
</h3>
<a
className="text-gray-500 block mt-1"
href="/@test-org"
onClick={[Function]}
onMouseEnter={[Function]}
>
test org
</a>
<div
className="leading-relaxed mt-2"
>
A description.
</div>
</div>
`;

View File

@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`📸 of Total component 1`] = `
<h1
className="text-4xl font-semibold text-primary"
>
2
results found
</h1>
`;