-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test suite for license decoration
- Loading branch information
Alex-At-Home
committed
Jul 16, 2020
1 parent
9d28194
commit 7649ab5
Showing
3 changed files
with
460 additions
and
18 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
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,89 @@ | ||
import renderer from 'react-test-renderer'; | ||
import React from 'react'; | ||
import { LineupDisplayUtils } from '../LineupDisplayUtils'; | ||
import { shallow } from 'enzyme' | ||
import toJson from 'enzyme-to-json' | ||
|
||
describe("LineupDisplayUtils", () => { | ||
|
||
const testLineup = [ | ||
{ code: "p1", id: "player1" }, | ||
{ code: "p2", id: "player2" }, | ||
{ code: "p3", id: "player3" }, | ||
{ code: "p4", id: "player4" }, | ||
{ code: "p5", id: "player5" }, | ||
]; | ||
const positionFromPlayerKey = { //(just used for display) | ||
"player1": { posClass: "p-PG" }, | ||
"player2": { posClass: "CG" }, | ||
"player3": { posClass: "WG" }, | ||
"player4": { posClass: "WF" }, | ||
"player5": { posClass: "PF/C" }, | ||
}; | ||
const perLineupPlayerMap = { | ||
"player1": { // *3* A | ||
off_rtg: { value: 101 }, off_adj_rtg: { value : 0.5 }, //(rtg just used for display) | ||
off_usage: { value: 0.1 }, off_assist: { value: 0.20 }, | ||
off_3pr: { value: 0.8 }, off_ftr: { value: 0.1 }, | ||
def_orb: { value: 0.05 }, //(just used for display) | ||
}, | ||
"player2": { // *A* *F* | ||
off_rtg: { value: 102 }, off_adj_rtg: { value : 1.0 }, //(rtg just used for display) | ||
off_usage: { value: 0.15 }, off_assist: { value: 0.30 }, | ||
off_3pr: { value: 0.3 }, off_ftr: { value: 0.9 }, | ||
def_orb: { value: 0.10 }, //(just used for display) | ||
}, | ||
"player3": { // *2* | ||
off_rtg: { value: 103 }, off_adj_rtg: { value : 1.5 }, //(rtg just used for display) | ||
off_usage: { value: 0.20 }, off_assist: { value: 0.15 }, | ||
off_3pr: { value: 0.01 }, off_ftr: { value: 0.3 }, | ||
def_orb: { value: 0.15 }, //(just used for display) | ||
}, | ||
"player4": { // 2 F | ||
off_rtg: { value: 104 }, off_adj_rtg: { value : 2.0 }, //(rtg just used for display) | ||
off_usage: { value: 0.25 }, off_assist: { value: 0.15 }, | ||
off_3pr: { value: 0.15 }, off_ftr: { value: 0.5 }, | ||
def_orb: { value: 0.20 }, //(just used for display) | ||
}, | ||
"player5": { // 3 A F | ||
off_rtg: { value: 105 }, off_adj_rtg: { value : 2.5 }, //(rtg just used for display) | ||
off_usage: { value: 0.30 }, off_assist: { value: 0.20 }, | ||
off_3pr: { value: 0.50 }, off_ftr: { value: 0.5 }, | ||
def_orb: { value: 0.25 }, //(just used for display) | ||
}, | ||
} | ||
|
||
test("buildDecoratedLineup - plain version", () => { | ||
const component = renderer.create( | ||
<span>{ | ||
LineupDisplayUtils.buildDecoratedLineup( | ||
"p1_p2_p3_p4_p5", testLineup, perLineupPlayerMap, positionFromPlayerKey, "off_adj_rtg", false | ||
) | ||
}</span> | ||
); | ||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
test("buildDecoratedLineup - decorated version", () => { | ||
const component = renderer.create( | ||
<span>{ | ||
LineupDisplayUtils.buildDecoratedLineup( | ||
"p1_p2_p3_p4_p5", testLineup, perLineupPlayerMap, positionFromPlayerKey, "off_adj_rtg", true | ||
) | ||
}</span> | ||
); | ||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
test("buildDecoratedLineup - buildTooltipTexts", () => { | ||
const component = renderer.create( | ||
<span>{ | ||
LineupDisplayUtils.buildTooltipTexts( | ||
"p1_p2_p3_p4_p5", testLineup, perLineupPlayerMap, positionFromPlayerKey | ||
) | ||
}</span> | ||
); | ||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.