Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Commit

Permalink
Added RevenueTest.test.js along with json file (graphql.json) to prov…
Browse files Browse the repository at this point in the history
…ide test data. Test generates or compares snap file
  • Loading branch information
mojobnichols committed Jul 5, 2019
1 parent bbc3e60 commit 1fe33f7
Show file tree
Hide file tree
Showing 5 changed files with 72,121 additions and 2 deletions.
15 changes: 15 additions & 0 deletions __mocks__/gatsby.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const React = require("react")
const gatsby = jest.requireActual("gatsby")

module.exports = {
...gatsby,
graphql: jest.fn(),
Link: jest.fn().mockImplementation(({ to, ...rest }) =>
React.createElement("a", {
...rest,
href: to,
})
),
StaticQuery: jest.fn(),
useStaticQuery: jest.fn(),
}
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
},
moduleNameMapper: {
".+\\.(css|styl|less|sass|scss)$": `identity-obj-proxy`,
".+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": `<rootDir>/__mocks__/file-mock.js`,
".+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|yml)$": `<rootDir>/__mocks__/file-mock.js`,
},
testPathIgnorePatterns: [`node_modules`, `.cache`],
transformIgnorePatterns: [`node_modules/(?!(gatsby)/)`],
Expand All @@ -13,4 +13,4 @@ module.exports = {
},
testURL: `http://localhost`,
setupFiles: [`<rootDir>/loadershim.js`],
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

import React from 'react'
import renderer from 'react-test-renderer'
import {StaticQuery, graphql} from 'gatsby'
import RevenueTrends from '../RevenueTrends'


//let data={foo:"bar"};
let {data} = require('./graphql.json');

beforeEach(() => {
StaticQuery.mockImplementationOnce(({ render }) =>
render(data)
)
})

describe('RevenueTrends', () => {
it('renders correctly', () => {
const tree = renderer
.create(<RevenueTrends />)
.toJSON()
expect(tree).toMatchSnapshot()
})
})


Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`RevenueTrends renders correctly 1`] = `
<section
className="root"
>
<h3
className="title h3-bar"
>
Revenue trends
</h3>
Includes federal and Native American revenue through
May
2019
<table
className="revenueTable"
>
<thead>
<tr>
<th>
10-year trend
</th>
<th
className="alignRight"
>
FY19 so far
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Royalties
</td>
<td
className="alignRight"
>
$6.62 billion
</td>
</tr>
<tr>
<td>
<div
style={
Object {
"fill": "none",
"stroke": "#5c737f",
"strokeWidth": 1,
}
}
/>
</td>
<td
className="alignRight"
>
<span>
<test-file-stub
viewBox="-20 -15 50 40"
/>
<span>
26%
</span>
</span>
from FY18
</td>
</tr>
<tr>
<td>
Bonuses
</td>
<td
className="alignRight"
>
$1.64 billion
</td>
</tr>
<tr>
<td>
<div
style={
Object {
"fill": "none",
"stroke": "#5c737f",
"strokeWidth": 1,
}
}
/>
</td>
<td
className="alignRight"
>
<span>
<test-file-stub
viewBox="-20 -15 50 40"
/>
<span>
413%
</span>
</span>
from FY18
</td>
</tr>
<tr>
<td>
Rents
</td>
<td
className="alignRight"
>
$73.80 million
</td>
</tr>
<tr>
<td>
<div
style={
Object {
"fill": "none",
"stroke": "#5c737f",
"strokeWidth": 1,
}
}
/>
</td>
<td
className="alignRight"
>
<span>
<test-file-stub
viewBox="-20 -15 50 40"
/>
<span>
2%
</span>
</span>
from FY18
</td>
</tr>
<tr>
<td>
Other revenues
</td>
<td
className="alignRight"
>
$103.00 million
</td>
</tr>
<tr>
<td>
<div
style={
Object {
"fill": "none",
"stroke": "#5c737f",
"strokeWidth": 1,
}
}
/>
</td>
<td
className="alignRight"
>
<span>
<test-file-stub
viewBox="-20 -10 50 40"
/>
<span>
-20%
</span>
</span>
from FY18
</td>
</tr>
<tr>
<td>
<strong>
Total revenues
</strong>
</td>
<td
className="alignRight"
>
<strong>
$8.44 billion
</strong>
</td>
</tr>
<tr>
<td>
<div
style={
Object {
"fill": "none",
"stroke": "#5c737f",
"strokeWidth": 1,
}
}
/>
</td>
<td
className="alignRight"
>
<span>
<test-file-stub
viewBox="-20 -15 50 40"
/>
<span>
46%
</span>
</span>
from FY18
</td>
</tr>
</tbody>
</table>
</section>
`;
Loading

0 comments on commit 1fe33f7

Please sign in to comment.