This repository has been archived by the owner on Nov 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added RevenueTest.test.js along with json file (graphql.json) to prov…
…ide test data. Test generates or compares snap file
- Loading branch information
1 parent
bbc3e60
commit 1fe33f7
Showing
5 changed files
with
72,121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/components/sections/RevenueTrends/__tests__/RevenueTrends.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) | ||
}) | ||
|
||
|
219 changes: 219 additions & 0 deletions
219
src/components/sections/RevenueTrends/__tests__/__snapshots__/RevenueTrends.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
`; |
Oops, something went wrong.