-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into no-more-this (WIP)
- Loading branch information
Showing
29 changed files
with
540 additions
and
57 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
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
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
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
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
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
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,45 @@ | ||
import { test } from "ava" | ||
import { rando, createHeros, createMonsters, createTreasure } from "./fixtures/fixture-data" | ||
import { Hero, Monster, Treasure } from "./fixtures/fixture-models" | ||
|
||
test("createHeros", t => { | ||
const data = createHeros(10) | ||
t.is(data.length, 10) | ||
const hero = Hero.create(data[0]) | ||
t.true(hero.descriptionLength > 1) | ||
}) | ||
|
||
test("createMonsters", t => { | ||
const data = createMonsters(10, 10, 10) | ||
t.is(data.length, 10) | ||
t.is(data[1].treasures.length, 10) | ||
t.is(data[0].eatenHeroes.length, 10) | ||
const monster = Monster.create(data[0]) | ||
t.true(monster.eatenHeroes && monster.eatenHeroes.length === 10) | ||
t.true(monster.treasures.length === 10) | ||
}) | ||
|
||
test("createTreasure", t => { | ||
const data = createTreasure(10) | ||
t.is(data.length, 10) | ||
const treasure = Treasure.create(data[1]) | ||
t.true(treasure.gold > 0) | ||
}) | ||
|
||
test("rando sorting", t => { | ||
// i'm going straight to hell for this test... must get coverage to 100%.... no matter the cost. | ||
let foundTrue = false | ||
let foundFalse = false | ||
let result | ||
do { | ||
result = rando() | ||
if (result) { | ||
foundTrue = true | ||
} else { | ||
foundFalse = true | ||
} | ||
} while (!foundTrue || !foundFalse) | ||
|
||
t.true(foundTrue) | ||
t.true(foundFalse) | ||
}) |
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,51 @@ | ||
import { test } from "ava" | ||
import { Hero, Monster, Treasure } from "./fixtures/fixture-models" | ||
import { unprotect } from "../src" | ||
|
||
const SAMPLE_HERO = { | ||
id: 1, | ||
name: "jimmy", | ||
level: 1, | ||
role: "cleric", | ||
description: "hi" | ||
} | ||
|
||
test("Hero computed fields", t => { | ||
const hero = Hero.create(SAMPLE_HERO) | ||
t.is(hero.descriptionLength, 2) | ||
}) | ||
|
||
test("Tresure", t => { | ||
const treasure = Treasure.create({ gold: 1, trapped: true }) | ||
t.true(treasure.trapped) | ||
t.is(treasure.gold, 1) | ||
}) | ||
|
||
test("Monster computed fields", t => { | ||
const monster = Monster.create({ | ||
id: "foo", | ||
level: 1, | ||
maxHp: 3, | ||
hp: 1, | ||
warning: "boo!", | ||
createdAt: new Date(), | ||
treasures: [{ gold: 2, trapped: true }, { gold: 3, trapped: true }], | ||
eatenHeroes: [SAMPLE_HERO], | ||
hasFangs: true, | ||
hasClaws: true, | ||
hasWings: true, | ||
hasGrowl: true | ||
}) | ||
t.true(monster.isAlive) | ||
t.true(monster.isFlashingRed) | ||
unprotect(monster) | ||
t.is(monster.weight, 2) | ||
monster.level = 0 | ||
monster.hasFangs = false | ||
monster.hasWings = false | ||
monster.eatenHeroes = null | ||
t.is(monster.weight, 1) | ||
monster.hp = 0 | ||
t.false(monster.isFlashingRed) | ||
t.false(monster.isAlive) | ||
}) |
Oops, something went wrong.