forked from IonPostglacial/hexagon-game-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.html
30 lines (29 loc) · 1.11 KB
/
tests.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE HTML>
<html>
<head>
<title>Playing with hexagons</title>
<link href="lib/qunit-1.22.0.css" rel="stylesheet">
<script src="lib/qunit-1.22.0.js"></script>
<script src="lib/require.js"></script>
<script>
requirejs(["lib/hexagon"], (hexagon) => {
"use strict";
const $ = document.querySelector.bind(document);
const oddGrid = {width: 15, height:13, radius: 32};
const evenGrid = {width: 15, height:12, radius: 32};
QUnit.test("Test allCoords", assert => {
const coordsCorrect = grid => Array.from(hexagon.grid.allCoords(grid)).every(coord => assert.ok(hexagon.grid.contains(grid, coord.x, coord.y), "Passed !"));
const rightNumberCoords = grid => assert.strictEqual(Array.from(hexagon.grid.allCoords(grid)).length, hexagon.grid.cellsNumber(grid), "Passed !");
coordsCorrect(oddGrid);
coordsCorrect(evenGrid);
rightNumberCoords(oddGrid);
rightNumberCoords(evenGrid);
});
});
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>