Skip to content

Commit 6dd9981

Browse files
committed
updated to ready-test and fixed most tests
1 parent 45cf03c commit 6dd9981

35 files changed

+1239
-1555
lines changed

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "Positionable!",
3+
"author": "Andrew Plummer <plummer.andrew@gmail.com>",
4+
"devDependencies": {
5+
"ready-test": "^1.1.0"
6+
}
7+
}

positionable.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5148,9 +5148,7 @@ class SpriteRecognizer {
51485148
context = canvas.getContext('2d');
51495149
context.drawImage(img, 0, 0);
51505150
this.pixelData = context.getImageData(0, 0, img.width, img.height).data;
5151-
this.width = img.width;
5152-
this.height = img.height;
5153-
this.map = new Array(this.width * this.height);
5151+
this.map = new Array(img.width * img.height);
51545152
}
51555153

51565154
// --- Testing Pixels
@@ -5179,12 +5177,12 @@ class SpriteRecognizer {
51795177
}
51805178

51815179
isValidPixel(pixel) {
5182-
return pixel.x >= 0 && pixel.x < this.width &&
5183-
pixel.y >= 0 && pixel.y < this.height;
5180+
return pixel.x >= 0 && pixel.x < this.img.width &&
5181+
pixel.y >= 0 && pixel.y < this.img.height;
51845182
}
51855183

51865184
getAlphaForPixel(pixel) {
5187-
return this.pixelData[(this.width * pixel.y + pixel.x) * 4 + 3];
5185+
return this.pixelData[(this.img.width * pixel.y + pixel.x) * 4 + 3];
51885186
}
51895187

51905188
// --- Pixel Map
@@ -5202,7 +5200,7 @@ class SpriteRecognizer {
52025200
}
52035201

52045202
getPixelIndex(pixel) {
5205-
return this.width * pixel.y + pixel.x;
5203+
return this.img.width * pixel.y + pixel.x;
52065204
}
52075205

52085206
}

test/.eslintrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"browser": true
5+
},
6+
"parserOptions": {
7+
"ecmaVersion": 2020
8+
},
9+
"extends": [
10+
"eslint:recommended"
11+
],
12+
"rules": {
13+
"no-redeclare": "off",
14+
"no-cond-assign": "off",
15+
"no-prototype-builtins": "off"
16+
},
17+
"globals": {
18+
"setup": "readonly"
19+
}
20+
}

test/helpers/assertions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
window.assertEqualWithTolerance = createAssertion((arg1, arg2, tolerance) => {
2+
return {
3+
pass: (arg1 >= arg2 - tolerance) && (arg1 <= arg2 + tolerance),
4+
message: `${arg1} should be within ${tolerance} of ${arg2}`,
5+
};
6+
});

test/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<title>Positionable Tests</title>
7-
<link rel="stylesheet" href="suite/simple-test.css">
7+
<link rel="stylesheet" href="../node_modules/ready-test/ready-test.css">
88
<link rel="stylesheet" href="styles/elements.css">
99
</head>
1010
<body>
1111
<div id="ui-fixtures" class="test-fixtures"></div>
1212
<div id="element-fixtures" class="test-fixtures"></div>
13-
<script src="suite/simple-test.js"></script>
13+
<script src="../node_modules/ready-test/ready-test.js" data-auto-run="false"></script>
1414
<script src="../positionable.js"></script>
1515

1616
<!-- Helpers -->
1717
<script src="helpers/ui.js"></script>
1818
<script src="helpers/events.js"></script>
1919
<script src="helpers/fixtures.js"></script>
20+
<script src="helpers/assertions.js"></script>
2021

2122
<!-- Mocks -->
2223
<script src="mocks/image.js"></script>
@@ -28,7 +29,6 @@
2829
<script src="mocks/scrolling.js"></script>
2930
<script src="mocks/set-timeout.js"></script>
3031
<script src="mocks/create-element.js"></script>
31-
<script src="mocks/google-payments.js"></script>
3232
<script src="mocks/window-dialogue.js"></script>
3333
<script src="mocks/css-rule-matcher.js"></script>
3434
<script src="mocks/document-fragment.js"></script>
@@ -39,7 +39,6 @@
3939
<script src="tests/nudge-manager.js"></script>
4040
<script src="tests/cursor-manager.js"></script>
4141
<script src="tests/output-manager.js"></script>
42-
<script src="tests/license-manager.js"></script>
4342
<script src="tests/alignment-manager.js"></script>
4443
<script src="tests/chrome-storage-manager.js"></script>
4544
<script src="tests/positionable-element-manager.js"></script>
@@ -76,7 +75,8 @@
7675
injector.setTemplate('ui.html');
7776
injector.setStylesheet('ui.css');
7877
injector.run(function(uiRoot) {
79-
window.testRunner.run(uiRoot);
78+
window.uiRoot = uiRoot;
79+
ReadyTest.run();
8080
});
8181

8282
</script>

test/mocks/google-payments.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

test/suite/simple-test.css

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)