[tests][m]: more tests for Search components.

This commit is contained in:
anuveyatsu
2020-06-17 16:40:04 +06:00
parent 2ecd88388a
commit ec646f1f10
9 changed files with 319 additions and 106 deletions

View File

@@ -0,0 +1,18 @@
import React from 'react'
import { render } from '@testing-library/react'
import renderer from 'react-test-renderer'
import Input from '../../../components/search/Input'
test('📸 of Input component with empty', () => {
const query = {}
const tree = renderer.create(<Input query={query} />).toJSON()
expect(tree).toMatchSnapshot()
})
test('📸 of Input component with query', () => {
const query = {
q: 'gdp'
}
const tree = renderer.create(<Input query={query} />).toJSON()
expect(tree).toMatchSnapshot()
})

View File

@@ -1,18 +0,0 @@
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,20 @@
import React from 'react'
import { render } from '@testing-library/react'
import renderer from 'react-test-renderer'
import List from '../../../components/search/List'
test('📸 of Input component with empty', () => {
const datapackages = [
{
name: 'test',
title: 'Title',
description: 'A description.',
organization: {
title: 'test org',
name: 'test-org'
}
}
]
const tree = renderer.create(<List datapackages={datapackages} />).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 Sort from '../../../components/search/Sort'
test('📸 of Input component with empty', () => {
const tree = renderer.create(<Sort />).toJSON()
expect(tree).toMatchSnapshot()
})

View File

@@ -0,0 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`📸 of Input component with empty 1`] = `
<form
className="flex items-center"
onSubmit={[Function]}
>
<input
aria-label="Search"
className="bg-white focus:outline-none focus:shadow-outline border border-gray-300 w-1/2 rounded-lg py-2 px-4 block appearance-none leading-normal"
name="q"
onChange={[Function]}
placeholder="Search"
type="text"
/>
<button
className="inline-block text-sm px-4 py-3 mx-3 leading-none border rounded text-white bg-black border-black lg:mt-0"
onClick={[Function]}
>
Search
</button>
</form>
`;
exports[`📸 of Input component with query 1`] = `
<form
className="flex items-center"
onSubmit={[Function]}
>
<input
aria-label="Search"
className="bg-white focus:outline-none focus:shadow-outline border border-gray-300 w-1/2 rounded-lg py-2 px-4 block appearance-none leading-normal"
name="q"
onChange={[Function]}
placeholder="Search"
type="text"
value="gdp"
/>
<button
className="inline-block text-sm px-4 py-3 mx-3 leading-none border rounded text-white bg-black border-black lg:mt-0"
onClick={[Function]}
>
Search
</button>
</form>
`;

View File

@@ -1,33 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`📸 of Item component 1`] = `
<div
className="mb-6"
>
<h3
className="text-xl 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,35 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`📸 of Input component with empty 1`] = `
<ul>
<div
className="mb-6"
>
<h3
className="text-xl 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>
</ul>
`;

View File

@@ -0,0 +1,44 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`📸 of Input component with empty 1`] = `
<div
className="inline-block my-6 float-right"
>
<label
htmlFor="field-order-by"
>
Order by:
</label>
<select
className="bg-white"
id="field-order-by"
name="sort"
>
<option
value="score:desc"
>
Relevance
</option>
<option
value="title_string:asc"
>
Name Ascending
</option>
<option
value="title_string:desc"
>
Name Descending
</option>
<option
value="metadata_modified:desc"
>
Last Modified
</option>
<option
value="views_recent:desc"
>
Popular
</option>
</select>
</div>
`;