Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix context in beforeEach call (unittest) #266

Merged
merged 4 commits into from
Jun 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/supplemental.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ describe("#calcSupplementalDamage", () => {
// generate temporary vals: [0, 0, 0, 0]
const INITIAL_VALS = (length=4, value=0) => (new Array(length)).fill(value);

let supplementalDamageArray;

beforeEach(() => {
this.supplementalDamageArray = {
supplementalDamageArray = {
"test-buff-a": {
damage: 10,
damageWithoutCritical: 10,
Expand All @@ -25,14 +27,12 @@ describe("#calcSupplementalDamage", () => {

describe("#calcOthersDamage", () => {
it("test single hit supplemental damage", () => {
let {supplementalDamageArray} = this;
let vals = supplemental.calcOthersDamage(supplementalDamageArray, INITIAL_VALS());
expect(vals.length).toBe(4);
expect(vals).toEqual([30, 30, 300, 500]);
});

it("test hp based supplemental damage", () => {
let {supplementalDamageArray} = this;
supplementalDamageArray['test-buff-a']['type'] = 'hp_based';
supplementalDamageArray['test-buff-a']['threshold'] = 0.80;

Expand All @@ -55,7 +55,6 @@ describe("#calcSupplementalDamage", () => {
});

it("test unknown type is ignored", () => {
let {supplementalDamageArray} = this;
supplementalDamageArray['test-buff-a']['type'] = undefined;
supplementalDamageArray['test-buff-b']['type'] = 'othr'; // assume typo case

Expand All @@ -78,7 +77,6 @@ describe("#calcSupplementalDamage", () => {

describe("#calcThirdHitDamage", () => {
it("test third hit supplemental damage", () => {
let {supplementalDamageArray} = this;
supplementalDamageArray['test-buff-a']['type'] = 'third_hit';

// default expectedTurn: 1
Expand All @@ -100,7 +98,6 @@ describe("#calcSupplementalDamage", () => {

// xit -> Skip test, `test.skip` for Jest
xit("test unknown report", () => {
let {supplementalDamageArray} = this;
supplementalDamageArray["test-buff-a"]["type"] = "unknown";

let vals = supplemental._calcDamage(["unknown"], supplementalDamageArray, INITIAL_VALS());
Expand All @@ -113,7 +110,7 @@ describe("#calcSupplementalDamage", () => {

describe("#collectSkillInfo", () => {
beforeEach(() => {
this.supplementalDamageArray = {
supplementalDamageArray = {
"D": { // for checking sort headers
damage: 10,
type: "other",
Expand Down Expand Up @@ -157,7 +154,6 @@ describe("#collectSkillInfo", () => {
// https://jestjs.io/docs/ja/api#testeachtable-name-fn-timeout
// (Jasmine in codepen.io did not support the same method)
it("test damageArray remainHP 100%,50%", () => {
let {supplementalDamageArray} = this;
const toKey = ([key, type, extraValue]) => key;

let supplementalInfo = supplemental.collectSkillInfo(supplementalDamageArray, {remainHP: 1.00});
Expand Down