Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Sep 8, 2023
1 parent 3c1adb2 commit 6a8bd4d
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/components/ItemView/Datasets/DatasetEsri.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import renderer from 'react-test-renderer';

import DatasetEsri from './DatasetEsri';

jest.mock('@eeacms/search', () => ({
runRequest: jest.fn(),
}));

const dataset = {
'ESRI:REST': [
{
id: 1,
url: 'https://example.org/1',
protocol: 'https',
name: 'First',
description: 'Something here',
},
],
};

describe('DatasetEsri', () => {
it('renders correctly', () => {
const tree = renderer.create(<DatasetEsri dataset={dataset} />).toJSON();
expect(tree).toMatchSnapshot();
});
});
38 changes: 38 additions & 0 deletions src/components/ItemView/Datasets/DatasetHttpLinks.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import renderer from 'react-test-renderer';

import DatasetHttpLinks from './DatasetHttpLinks';

jest.mock('@eeacms/search', () => ({
runRequest: jest.fn(),
}));

const dataset = {
'WWW:LINK-1.0-http--link': [
{
id: 1,
url: 'https://example.org/1',
protocol: 'https',
name: 'First',
description: 'Something here',
},
],
DOI: [
{
id: 1,
url: 'https://example.org/1',
protocol: 'https',
name: 'First',
description: 'Something here',
},
],
};

describe('DatasetHttpLinks', () => {
it('renders correctly', () => {
const tree = renderer
.create(<DatasetHttpLinks dataset={dataset} />)
.toJSON();
expect(tree).toMatchSnapshot();
});
});
27 changes: 27 additions & 0 deletions src/components/ItemView/Datasets/DatasetLinks.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import renderer from 'react-test-renderer';

import DatasetLinks from './DatasetLinks';

jest.mock('@eeacms/search', () => ({
runRequest: jest.fn(),
}));

const dataset = {
'WWW:LINK': [
{
id: 1,
url: 'https://example.org/1',
protocol: 'https',
name: 'First',
description: 'Something here',
},
],
};

describe('DatasetEsri', () => {
it('renders correctly', () => {
const tree = renderer.create(<DatasetLinks dataset={dataset} />).toJSON();
expect(tree).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DatasetEsri renders correctly 1`] = `
Array [
<h5>
Services:
</h5>,
<div
className="ui divided relaxed list"
role="list"
>
<div
className="item"
onClick={[Function]}
role="listitem"
>
<div
className="content"
>
<div>
<svg
className="icon"
dangerouslySetInnerHTML={
Object {
"__html": undefined,
}
}
style={
Object {
"fill": "currentColor",
"height": "20px",
"width": "auto",
}
}
/>
<a
className="item-link"
href="https://example.org/1"
rel="noreferrer"
target="_blank"
>
https
First
</a>
</div>
</div>
</div>
</div>,
]
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DatasetHttpLinks renders correctly 1`] = `
Array [
<h5>
Links:
</h5>,
<div
className="ui divided relaxed list"
role="list"
>
<div
className="item"
onClick={[Function]}
role="listitem"
>
<div
className="content"
>
<div
className="dataset-item"
>
<i
aria-hidden="true"
className="icon linkify"
onClick={[Function]}
/>
<a
className="item-link"
href="https://example.org/1"
rel="noreferrer"
target="_blank"
>
<span>
First
</span>
</a>
</div>
</div>
<span
className="item-description"
>
Something here
</span>
</div>
<div
className="item"
onClick={[Function]}
role="listitem"
>
<div
className="content"
>
<div
className="dataset-item"
>
<i
aria-hidden="true"
className="icon info circle"
onClick={[Function]}
/>
<a
className="item-link"
href="https://example.org/1"
rel="noreferrer"
target="_blank"
>
<span>
First
</span>
</a>
</div>
</div>
<span
className="item-description"
>
Something here
</span>
</div>
</div>,
]
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DatasetEsri renders correctly 1`] = `
<div
className="item"
onClick={[Function]}
role="listitem"
>
<div
className="content"
>
<div
className="dataset-item"
>
<i
aria-hidden="true"
className="icon download"
onClick={[Function]}
/>
<a
className="item-link"
href="https://example.org/1"
rel="noreferrer"
target="_blank"
>
First
</a>
</div>
</div>
</div>
`;

0 comments on commit 6a8bd4d

Please sign in to comment.