@deck.gl/test-utils 9.0.0-beta.2 → 9.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generate-layer-tests.d.ts +20 -0
- package/dist/generate-layer-tests.d.ts.map +1 -0
- package/dist/generate-layer-tests.js +209 -0
- package/dist/index.cjs +645 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/interaction-test-runner.d.ts +29 -0
- package/dist/interaction-test-runner.d.ts.map +1 -0
- package/dist/interaction-test-runner.js +57 -0
- package/dist/lifecycle-test.d.ts +119 -0
- package/dist/lifecycle-test.d.ts.map +1 -0
- package/dist/lifecycle-test.js +232 -0
- package/dist/snapshot-test-runner.d.ts +46 -0
- package/dist/snapshot-test-runner.d.ts.map +1 -0
- package/dist/snapshot-test-runner.js +101 -0
- package/dist/test-runner.d.ts +56 -0
- package/dist/test-runner.d.ts.map +1 -0
- package/dist/test-runner.js +143 -0
- package/dist/utils/dom.d.ts +7 -0
- package/dist/utils/dom.d.ts.map +1 -0
- package/dist/utils/dom.js +11 -0
- package/dist/utils/precision.d.ts +4 -0
- package/dist/utils/precision.d.ts.map +1 -0
- package/dist/utils/precision.js +19 -0
- package/dist/utils/setup-gl.d.ts +5 -0
- package/dist/utils/setup-gl.d.ts.map +1 -0
- package/dist/utils/setup-gl.js +15 -0
- package/package.json +15 -6
- package/src/generate-layer-tests.ts +54 -15
- package/src/index.ts +6 -3
- package/src/interaction-test-runner.ts +29 -13
- package/src/lifecycle-test.ts +214 -27
- package/src/snapshot-test-runner.ts +79 -47
- package/src/test-runner.ts +76 -58
- package/src/utils/dom.ts +6 -1
- package/src/utils/precision.ts +13 -6
- package/dist/es5/generate-layer-tests.js +0 -243
- package/dist/es5/generate-layer-tests.js.map +0 -1
- package/dist/es5/index.js +0 -88
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/interaction-test-runner.js +0 -119
- package/dist/es5/interaction-test-runner.js.map +0 -1
- package/dist/es5/lifecycle-test.js +0 -456
- package/dist/es5/lifecycle-test.js.map +0 -1
- package/dist/es5/snapshot-test-runner.js +0 -145
- package/dist/es5/snapshot-test-runner.js.map +0 -1
- package/dist/es5/test-runner.js +0 -198
- package/dist/es5/test-runner.js.map +0 -1
- package/dist/es5/utils/dom.js +0 -17
- package/dist/es5/utils/dom.js.map +0 -1
- package/dist/es5/utils/precision.js +0 -33
- package/dist/es5/utils/precision.js.map +0 -1
- package/dist/es5/utils/setup-gl.js +0 -19
- package/dist/es5/utils/setup-gl.js.map +0 -1
- package/dist/esm/generate-layer-tests.js +0 -216
- package/dist/esm/generate-layer-tests.js.map +0 -1
- package/dist/esm/index.js +0 -8
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/interaction-test-runner.js +0 -52
- package/dist/esm/interaction-test-runner.js.map +0 -1
- package/dist/esm/lifecycle-test.js +0 -282
- package/dist/esm/lifecycle-test.js.map +0 -1
- package/dist/esm/snapshot-test-runner.js +0 -94
- package/dist/esm/snapshot-test-runner.js.map +0 -1
- package/dist/esm/test-runner.js +0 -134
- package/dist/esm/test-runner.js.map +0 -1
- package/dist/esm/utils/dom.js +0 -10
- package/dist/esm/utils/dom.js.map +0 -1
- package/dist/esm/utils/precision.js +0 -18
- package/dist/esm/utils/precision.js.map +0 -1
- package/dist/esm/utils/setup-gl.js +0 -9
- package/dist/esm/utils/setup-gl.js.map +0 -1
package/src/test-runner.ts
CHANGED
|
@@ -20,22 +20,39 @@
|
|
|
20
20
|
|
|
21
21
|
/* global window, console */
|
|
22
22
|
/* eslint-disable no-console */
|
|
23
|
-
import {Deck, MapView} from '@deck.gl/core';
|
|
23
|
+
import {Deck, DeckProps, MapView} from '@deck.gl/core';
|
|
24
|
+
import type {Device} from '@luma.gl/core';
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const DEFAULT_DECK_PROPS = {
|
|
26
|
+
const DEFAULT_DECK_PROPS: DeckProps = {
|
|
28
27
|
...Deck.defaultProps,
|
|
29
28
|
id: 'deckgl-render-test',
|
|
30
29
|
width: 800,
|
|
31
30
|
height: 450,
|
|
32
31
|
style: {position: 'absolute', left: '0px', top: '0px'},
|
|
33
|
-
views: [new MapView()],
|
|
32
|
+
views: [new MapView({})],
|
|
34
33
|
useDevicePixels: false,
|
|
35
34
|
debug: true
|
|
36
35
|
};
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
export type TestCase = {
|
|
38
|
+
name: string;
|
|
39
|
+
/** milliseconds to wait before aborting */
|
|
40
|
+
timeout?: number;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type TestOptions<TestCaseT extends TestCase, ResultT> = {
|
|
44
|
+
/** Called when a test case starts */
|
|
45
|
+
onTestStart: (testCase: TestCaseT) => void;
|
|
46
|
+
/** Called when a test case passes */
|
|
47
|
+
onTestPass: (testCase: TestCaseT, result: ResultT) => void;
|
|
48
|
+
/** Called when a test case fails */
|
|
49
|
+
onTestFail: (testCase: TestCaseT, result: ResultT | {error: string}) => void;
|
|
50
|
+
|
|
51
|
+
/** milliseconds to wait for each test case before aborting */
|
|
52
|
+
timeout: number;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const DEFAULT_TEST_OPTIONS: TestOptions<TestCase, unknown> = {
|
|
39
56
|
// test lifecycle callback
|
|
40
57
|
onTestStart: testCase => console.log(`# ${testCase.name}`),
|
|
41
58
|
onTestPass: testCase => console.log(`ok ${testCase.name} passed`),
|
|
@@ -45,35 +62,39 @@ const DEFAULT_TEST_OPTIONS = {
|
|
|
45
62
|
timeout: 2000
|
|
46
63
|
};
|
|
47
64
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
export abstract class TestRunner<TestCaseT extends TestCase, ResultT, ExtraOptions = {}> {
|
|
66
|
+
deck: Deck | null = null;
|
|
67
|
+
props: DeckProps;
|
|
68
|
+
isHeadless: boolean;
|
|
69
|
+
isRunning: boolean = false;
|
|
70
|
+
testOptions: TestOptions<TestCaseT, ResultT> & ExtraOptions;
|
|
71
|
+
gpuVendor?: string;
|
|
72
|
+
|
|
73
|
+
private _testCases: TestCaseT[] = [];
|
|
74
|
+
private _currentTestCase: TestCaseT | null = null;
|
|
75
|
+
private _testCaseData: unknown = null;
|
|
51
76
|
|
|
52
|
-
export default class TestRunner {
|
|
53
77
|
/**
|
|
54
78
|
* props
|
|
55
79
|
* Deck props
|
|
56
80
|
*/
|
|
57
|
-
constructor(props = {}) {
|
|
81
|
+
constructor(props: DeckProps = {}, options: ExtraOptions) {
|
|
58
82
|
this.props = {...DEFAULT_DECK_PROPS, ...props};
|
|
59
83
|
|
|
60
|
-
|
|
61
|
-
this._testCases = [];
|
|
62
|
-
this._testCaseData = null;
|
|
63
|
-
|
|
84
|
+
// @ts-ignore browserTestDriver_isHeadless is injected by @probe.gl/test-utils if running in headless browser
|
|
64
85
|
this.isHeadless = Boolean(window.browserTestDriver_isHeadless);
|
|
65
86
|
|
|
66
|
-
this.testOptions = {...DEFAULT_TEST_OPTIONS};
|
|
87
|
+
this.testOptions = {...DEFAULT_TEST_OPTIONS, ...options};
|
|
67
88
|
}
|
|
68
89
|
|
|
69
|
-
get defaultTestCase() {
|
|
70
|
-
|
|
90
|
+
get defaultTestCase(): TestCaseT {
|
|
91
|
+
throw new Error('Not implemented');
|
|
71
92
|
}
|
|
72
93
|
|
|
73
94
|
/**
|
|
74
95
|
* Add testCase(s)
|
|
75
96
|
*/
|
|
76
|
-
add(testCases) {
|
|
97
|
+
add(testCases: TestCaseT[]): this {
|
|
77
98
|
if (!Array.isArray(testCases)) {
|
|
78
99
|
testCases = [testCases];
|
|
79
100
|
}
|
|
@@ -86,13 +107,13 @@ export default class TestRunner {
|
|
|
86
107
|
/**
|
|
87
108
|
* Returns a promise that resolves when all the test cases are done
|
|
88
109
|
*/
|
|
89
|
-
run(options = {}) {
|
|
110
|
+
run(options: Partial<TestOptions<TestCaseT, ResultT> & ExtraOptions> = {}): Promise<void> {
|
|
90
111
|
Object.assign(this.testOptions, options);
|
|
91
112
|
|
|
92
|
-
return new Promise((resolve, reject) => {
|
|
113
|
+
return new Promise<void>((resolve, reject) => {
|
|
93
114
|
this.deck = new Deck({
|
|
94
115
|
...this.props,
|
|
95
|
-
|
|
116
|
+
onDeviceInitialized: this._onDeviceInitialized.bind(this),
|
|
96
117
|
onLoad: resolve
|
|
97
118
|
});
|
|
98
119
|
|
|
@@ -107,18 +128,18 @@ export default class TestRunner {
|
|
|
107
128
|
});
|
|
108
129
|
return promise;
|
|
109
130
|
})
|
|
110
|
-
.catch(error => {
|
|
111
|
-
this.
|
|
131
|
+
.catch((error: unknown) => {
|
|
132
|
+
this.fail({error: (error as Error).message});
|
|
112
133
|
})
|
|
113
134
|
.finally(() => {
|
|
114
|
-
this.deck
|
|
135
|
+
this.deck!.finalize();
|
|
115
136
|
this.deck = null;
|
|
116
137
|
});
|
|
117
138
|
}
|
|
118
139
|
|
|
119
140
|
/* Lifecycle methods for subclassing */
|
|
120
141
|
|
|
121
|
-
initTestCase(testCase) {
|
|
142
|
+
initTestCase(testCase: TestCaseT) {
|
|
122
143
|
for (const key in this.defaultTestCase) {
|
|
123
144
|
if (!(key in testCase)) {
|
|
124
145
|
testCase[key] = this.defaultTestCase[key];
|
|
@@ -127,51 +148,48 @@ export default class TestRunner {
|
|
|
127
148
|
this.testOptions.onTestStart(testCase);
|
|
128
149
|
}
|
|
129
150
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
/** Execute the test case. Fails if takes longer than options.timeout */
|
|
152
|
+
abstract runTestCase(testCase: TestCaseT): Promise<void>;
|
|
153
|
+
/** Check the result of the test case. Calls pass() or fail() */
|
|
154
|
+
abstract assert(testCase: TestCaseT): Promise<void>;
|
|
134
155
|
|
|
135
156
|
/* Utilities */
|
|
136
157
|
|
|
137
|
-
|
|
138
|
-
this.testOptions.onTestPass(this._currentTestCase
|
|
158
|
+
protected pass(result: ResultT) {
|
|
159
|
+
this.testOptions.onTestPass(this._currentTestCase!, result);
|
|
139
160
|
}
|
|
140
161
|
|
|
141
|
-
|
|
142
|
-
this.testOptions.onTestFail(this._currentTestCase
|
|
162
|
+
protected fail(result: ResultT | {error: string}) {
|
|
163
|
+
this.testOptions.onTestFail(this._currentTestCase!, result);
|
|
143
164
|
}
|
|
144
165
|
|
|
145
166
|
/* Private Methods */
|
|
146
167
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const ext = gl.getExtension('WEBGL_debug_renderer_info');
|
|
150
|
-
const vendorUnmasked = ext && gl.getParameter(ext.UNMASKED_VENDOR_WEBGL || GL_VENDOR);
|
|
151
|
-
this.gpuVendor = vendorUnmasked || vendorMasked;
|
|
168
|
+
private _onDeviceInitialized(device: Device) {
|
|
169
|
+
this.gpuVendor = device.info.vendor;
|
|
152
170
|
}
|
|
153
171
|
|
|
154
|
-
_runTest(testCase) {
|
|
155
|
-
|
|
156
|
-
this._currentTestCase = testCase;
|
|
157
|
-
this._next = resolve;
|
|
158
|
-
|
|
159
|
-
// normalize test case
|
|
160
|
-
this.initTestCase(testCase);
|
|
161
|
-
|
|
162
|
-
let isDone = false;
|
|
163
|
-
let timeoutId = null;
|
|
164
|
-
const done = () => {
|
|
165
|
-
if (!isDone) {
|
|
166
|
-
isDone = true;
|
|
167
|
-
window.clearTimeout(timeoutId);
|
|
168
|
-
this.assert(testCase);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
172
|
+
private async _runTest(testCase: TestCaseT) {
|
|
173
|
+
this._currentTestCase = testCase;
|
|
171
174
|
|
|
172
|
-
|
|
175
|
+
// normalize test case
|
|
176
|
+
this.initTestCase(testCase);
|
|
173
177
|
|
|
174
|
-
|
|
178
|
+
const timeout = testCase.timeout || this.testOptions.timeout;
|
|
179
|
+
const task = this.runTestCase(testCase);
|
|
180
|
+
const timeoutTask = new Promise((_, reject) => {
|
|
181
|
+
setTimeout(() => {
|
|
182
|
+
reject('Timeout');
|
|
183
|
+
}, timeout);
|
|
175
184
|
});
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
await Promise.race([task, timeoutTask]);
|
|
188
|
+
await this.assert(testCase);
|
|
189
|
+
} catch (err: unknown) {
|
|
190
|
+
if (err === 'Timeout') {
|
|
191
|
+
this.fail({error: 'Timeout'});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
176
194
|
}
|
|
177
195
|
}
|
package/src/utils/dom.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/* global window */
|
|
2
2
|
// Get the bounding box of a DOMElement relative to the page
|
|
3
|
-
export function getBoundingBoxInPage(domElement) {
|
|
3
|
+
export function getBoundingBoxInPage(domElement: HTMLElement): {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
} {
|
|
4
9
|
const bbox = domElement.getBoundingClientRect();
|
|
5
10
|
return {
|
|
6
11
|
x: window.scrollX + bbox.x,
|
package/src/utils/precision.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
+
export function toLowPrecision(input: number, precision?: number): number;
|
|
2
|
+
export function toLowPrecision(input: number[], precision?: number): number[];
|
|
3
|
+
export function toLowPrecision(
|
|
4
|
+
input: Record<string, number>,
|
|
5
|
+
precision?: number
|
|
6
|
+
): Record<string, number>;
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Covert all numbers in a deep structure to a given precision, allowing
|
|
3
10
|
* reliable float comparisons. Converts data in-place.
|
|
4
|
-
* @param {mixed} input Input data
|
|
5
|
-
* @param {Number} [precision] Desired precision
|
|
6
|
-
* @return {mixed} Input data, with all numbers converted
|
|
7
11
|
*/
|
|
8
|
-
export function toLowPrecision(
|
|
12
|
+
export function toLowPrecision(
|
|
13
|
+
input: number | number[] | Record<string, number>,
|
|
14
|
+
precision: number = 11
|
|
15
|
+
): number | number[] | Record<string, number> {
|
|
9
16
|
/* eslint-disable guard-for-in */
|
|
10
17
|
if (typeof input === 'number') {
|
|
11
|
-
|
|
18
|
+
return Number(input.toPrecision(precision));
|
|
12
19
|
}
|
|
13
20
|
if (Array.isArray(input)) {
|
|
14
|
-
|
|
21
|
+
return input.map(item => toLowPrecision(item, precision));
|
|
15
22
|
}
|
|
16
23
|
if (typeof input === 'object') {
|
|
17
24
|
for (const key in input) {
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.generateLayerTests = generateLayerTests;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
-
|
|
16
|
-
var _core = require("@deck.gl/core");
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
|
-
function noop() {}
|
|
23
|
-
|
|
24
|
-
function defaultAssert(condition, comment) {
|
|
25
|
-
if (!condition) {
|
|
26
|
-
throw new Error(comment);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function generateLayerTests(_ref) {
|
|
31
|
-
var Layer = _ref.Layer,
|
|
32
|
-
_ref$sampleProps = _ref.sampleProps,
|
|
33
|
-
sampleProps = _ref$sampleProps === void 0 ? {} : _ref$sampleProps,
|
|
34
|
-
_ref$assert = _ref.assert,
|
|
35
|
-
assert = _ref$assert === void 0 ? defaultAssert : _ref$assert,
|
|
36
|
-
_ref$onBeforeUpdate = _ref.onBeforeUpdate,
|
|
37
|
-
onBeforeUpdate = _ref$onBeforeUpdate === void 0 ? noop : _ref$onBeforeUpdate,
|
|
38
|
-
_ref$onAfterUpdate = _ref.onAfterUpdate,
|
|
39
|
-
onAfterUpdate = _ref$onAfterUpdate === void 0 ? noop : _ref$onAfterUpdate,
|
|
40
|
-
_ref$runDefaultAssert = _ref.runDefaultAsserts,
|
|
41
|
-
runDefaultAsserts = _ref$runDefaultAssert === void 0 ? true : _ref$runDefaultAssert;
|
|
42
|
-
assert(Layer.layerName, 'Layer should have display name');
|
|
43
|
-
|
|
44
|
-
function wrapTestCaseTitle(title) {
|
|
45
|
-
return "".concat(Layer.layerName, "#").concat(title);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var testCases = [{
|
|
49
|
-
title: 'Empty props',
|
|
50
|
-
props: {}
|
|
51
|
-
}, {
|
|
52
|
-
title: 'Null data',
|
|
53
|
-
updateProps: {
|
|
54
|
-
data: null
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
title: 'Sample data',
|
|
58
|
-
updateProps: sampleProps
|
|
59
|
-
}];
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
new Layer({});
|
|
63
|
-
} catch (error) {
|
|
64
|
-
assert(false, "Construct ".concat(Layer.layerName, " throws: ").concat(error.message));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
var propTypes = Layer._propTypes,
|
|
68
|
-
defaultProps = Layer._mergedDefaultProps;
|
|
69
|
-
testCases.push.apply(testCases, (0, _toConsumableArray2.default)(makeAltDataTestCases(sampleProps, propTypes)));
|
|
70
|
-
|
|
71
|
-
for (var propName in Layer.defaultProps) {
|
|
72
|
-
if (!(propName in sampleProps)) {
|
|
73
|
-
var newTestCase = makeAltPropTestCase({
|
|
74
|
-
propName: propName,
|
|
75
|
-
propTypes: propTypes,
|
|
76
|
-
defaultProps: defaultProps,
|
|
77
|
-
sampleProps: sampleProps,
|
|
78
|
-
assert: assert
|
|
79
|
-
}) || [];
|
|
80
|
-
testCases.push.apply(testCases, (0, _toConsumableArray2.default)(newTestCase));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
testCases.forEach(function (testCase) {
|
|
85
|
-
testCase.title = wrapTestCaseTitle(testCase.title);
|
|
86
|
-
var beforeFunc = testCase.onBeforeUpdate || noop;
|
|
87
|
-
var afterFunc = testCase.onAfterUpdate || noop;
|
|
88
|
-
|
|
89
|
-
testCase.onBeforeUpdate = function (params) {
|
|
90
|
-
beforeFunc(params);
|
|
91
|
-
onBeforeUpdate(params);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
testCase.onAfterUpdate = function (params) {
|
|
95
|
-
afterFunc(params);
|
|
96
|
-
onAfterUpdate(params);
|
|
97
|
-
|
|
98
|
-
if (runDefaultAsserts) {
|
|
99
|
-
if (params.layer.isComposite) {
|
|
100
|
-
var data = params.layer.props.data;
|
|
101
|
-
|
|
102
|
-
if (data && (0, _typeof2.default)(data) === 'object' && (0, _core._count)(data)) {
|
|
103
|
-
assert(params.subLayers.length, 'Layer should have sublayers');
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
assert(params.layer.getModels().length, 'Layer should have models');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
return testCases;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function makeAltPropTestCase(_ref2) {
|
|
115
|
-
var propName = _ref2.propName,
|
|
116
|
-
propTypes = _ref2.propTypes,
|
|
117
|
-
defaultProps = _ref2.defaultProps,
|
|
118
|
-
sampleProps = _ref2.sampleProps,
|
|
119
|
-
assert = _ref2.assert;
|
|
120
|
-
|
|
121
|
-
var newProps = _objectSpread({}, sampleProps);
|
|
122
|
-
|
|
123
|
-
var propDef = propTypes[propName];
|
|
124
|
-
|
|
125
|
-
if (!propDef) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
switch (propDef.type) {
|
|
130
|
-
case 'boolean':
|
|
131
|
-
newProps[propName] = !defaultProps[propName];
|
|
132
|
-
return [{
|
|
133
|
-
title: "".concat(propName, ": ").concat(String(newProps[propName])),
|
|
134
|
-
props: newProps
|
|
135
|
-
}];
|
|
136
|
-
|
|
137
|
-
case 'number':
|
|
138
|
-
if ('max' in propDef) {
|
|
139
|
-
newProps[propName] = propDef.max;
|
|
140
|
-
} else if ('min' in propDef) {
|
|
141
|
-
newProps[propName] = propDef.min;
|
|
142
|
-
} else {
|
|
143
|
-
newProps[propName] = defaultProps[propName] + 1;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return [{
|
|
147
|
-
title: "".concat(propName, ": ").concat(String(newProps[propName])),
|
|
148
|
-
props: newProps
|
|
149
|
-
}];
|
|
150
|
-
|
|
151
|
-
case 'accessor':
|
|
152
|
-
{
|
|
153
|
-
if (typeof defaultProps[propName] === 'function') {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
var callCount = 0;
|
|
158
|
-
|
|
159
|
-
newProps[propName] = function () {
|
|
160
|
-
callCount++;
|
|
161
|
-
return defaultProps[propName];
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
newProps.updateTriggers = (0, _defineProperty2.default)({}, propName, 'function');
|
|
165
|
-
|
|
166
|
-
var onBeforeUpdate = function onBeforeUpdate() {
|
|
167
|
-
return callCount = 0;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
var onAfterUpdate = function onAfterUpdate() {
|
|
171
|
-
return assert(callCount > 0, 'accessor function is called');
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
return [{
|
|
175
|
-
title: "".concat(propName, ": () => ").concat(defaultProps[propName]),
|
|
176
|
-
props: newProps,
|
|
177
|
-
onBeforeUpdate: onBeforeUpdate,
|
|
178
|
-
onAfterUpdate: onAfterUpdate
|
|
179
|
-
}, {
|
|
180
|
-
title: "".concat(propName, ": updateTrigger"),
|
|
181
|
-
updateProps: {
|
|
182
|
-
updateTriggers: (0, _defineProperty2.default)({}, propName, 'function+trigger')
|
|
183
|
-
},
|
|
184
|
-
onBeforeUpdate: onBeforeUpdate,
|
|
185
|
-
onAfterUpdate: onAfterUpdate
|
|
186
|
-
}];
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
default:
|
|
190
|
-
return null;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function makeAltDataTestCases(props, propTypes) {
|
|
195
|
-
var originalData = props.data;
|
|
196
|
-
|
|
197
|
-
if (!Array.isArray(originalData)) {
|
|
198
|
-
return [];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
var partialUpdateProps = {
|
|
202
|
-
data: originalData.slice(),
|
|
203
|
-
_dataDiff: function _dataDiff() {
|
|
204
|
-
return [{
|
|
205
|
-
startRow: 0,
|
|
206
|
-
endRow: 2
|
|
207
|
-
}];
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
var genIterableProps = {
|
|
211
|
-
data: new Set(originalData),
|
|
212
|
-
_dataDiff: null
|
|
213
|
-
};
|
|
214
|
-
var nonIterableProps = {
|
|
215
|
-
data: {
|
|
216
|
-
length: originalData.length
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
var _loop = function _loop(propName) {
|
|
221
|
-
if (propTypes[propName].type === 'accessor') {
|
|
222
|
-
nonIterableProps[propName] = function (_, info) {
|
|
223
|
-
return props[propName](originalData[info.index], info);
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
for (var propName in props) {
|
|
229
|
-
_loop(propName);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return [{
|
|
233
|
-
title: 'Partial update',
|
|
234
|
-
updateProps: partialUpdateProps
|
|
235
|
-
}, {
|
|
236
|
-
title: 'Generic iterable data',
|
|
237
|
-
updateProps: genIterableProps
|
|
238
|
-
}, {
|
|
239
|
-
title: 'non-iterable data',
|
|
240
|
-
updateProps: nonIterableProps
|
|
241
|
-
}];
|
|
242
|
-
}
|
|
243
|
-
//# sourceMappingURL=generate-layer-tests.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/generate-layer-tests.ts"],"names":["noop","defaultAssert","condition","comment","Error","generateLayerTests","Layer","sampleProps","assert","onBeforeUpdate","onAfterUpdate","runDefaultAsserts","layerName","wrapTestCaseTitle","title","testCases","props","updateProps","data","error","message","propTypes","_propTypes","defaultProps","_mergedDefaultProps","push","makeAltDataTestCases","propName","newTestCase","makeAltPropTestCase","forEach","testCase","beforeFunc","afterFunc","params","layer","isComposite","subLayers","length","getModels","newProps","propDef","type","String","max","min","callCount","updateTriggers","originalData","Array","isArray","partialUpdateProps","slice","_dataDiff","startRow","endRow","genIterableProps","Set","nonIterableProps","_","info","index"],"mappings":";;;;;;;;;;;;;;;AAmBA;;;;;;AAGA,SAASA,IAAT,GAAgB,CAAE;;AAElB,SAASC,aAAT,CAAuBC,SAAvB,EAAkCC,OAAlC,EAA2C;AACzC,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,CAAUD,OAAV,CAAN;AACD;AACF;;AAGM,SAASE,kBAAT,OAOJ;AAAA,MANDC,KAMC,Q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,EAAkC;AAChC,WAAO,EAAP;AACD;;AAED,MAAMG,kBAAkB,GAAG;AACzBjC,IAAAA,IAAI,EAAE8B,YAAY,CAACI,KAAb,EADmB;AAEzBC,IAAAA,SAAS,EAAE;AAAA,aAAM,CAAC;AAACC,QAAAA,QAAQ,EAAE,CAAX;AAAcC,QAAAA,MAAM,EAAE;AAAtB,OAAD,CAAN;AAAA;AAFc,GAA3B;AAKA,MAAMC,gBAAgB,GAAG;AACvBtC,IAAAA,IAAI,EAAE,IAAIuC,GAAJ,CAAQT,YAAR,CADiB;AAEvBK,IAAAA,SAAS,EAAE;AAFY,GAAzB;AAKA,MAAMK,gBAAgB,GAAG;AACvBxC,IAAAA,IAAI,EAAE;AACJoB,MAAAA,MAAM,EAAEU,YAAY,CAACV;AADjB;AADiB,GAAzB;;AAhB8C,6BAqBnCX,QArBmC;AAsB5C,QAAIN,SAAS,CAACM,QAAD,CAAT,CAAoBe,IAApB,KAA6B,UAAjC,EAA6C;AAC3CgB,MAAAA,gBAAgB,CAAC/B,QAAD,CAAhB,GAA6B,UAACgC,CAAD,EAAIC,IAAJ;AAAA,eAAa5C,KAAK,CAACW,QAAD,CAAL,CAAgBqB,YAAY,CAACY,IAAI,CAACC,KAAN,CAA5B,EAA0CD,IAA1C,CAAb;AAAA,OAA7B;AACD;AAxB2C;;AAqB9C,OAAK,IAAMjC,QAAX,IAAuBX,KAAvB,EAA8B;AAAA,UAAnBW,QAAmB;AAI7B;;AAED,SAAO,CACL;AACEb,IAAAA,KAAK,EAAE,gBADT;AAEEG,IAAAA,WAAW,EAAEkC;AAFf,GADK,EAKL;AACErC,IAAAA,KAAK,EAAE,uBADT;AAEEG,IAAAA,WAAW,EAAEuC;AAFf,GALK,EASL;AACE1C,IAAAA,KAAK,EAAE,mBADT;AAEEG,IAAAA,WAAW,EAAEyC;AAFf,GATK,CAAP;AAcD","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\nimport {_count as count} from '@deck.gl/core';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction noop() {}\n\nfunction defaultAssert(condition, comment) {\n if (!condition) {\n throw new Error(comment);\n }\n}\n\n// Automatically generate testLayer test cases\nexport function generateLayerTests({\n Layer,\n sampleProps = {},\n assert = defaultAssert,\n onBeforeUpdate = noop,\n onAfterUpdate = noop,\n runDefaultAsserts = true\n}) {\n assert(Layer.layerName, 'Layer should have display name');\n\n function wrapTestCaseTitle(title) {\n return `${Layer.layerName}#${title}`;\n }\n\n const testCases = [\n {\n title: 'Empty props',\n props: {}\n },\n {\n title: 'Null data',\n updateProps: {data: null}\n },\n {\n title: 'Sample data',\n updateProps: sampleProps\n }\n ];\n\n try {\n // Calling constructor for the first time resolves default props\n // eslint-disable-next-line\n new Layer({});\n } catch (error) {\n assert(false, `Construct ${Layer.layerName} throws: ${error.message}`);\n }\n\n const {_propTypes: propTypes, _mergedDefaultProps: defaultProps} = Layer;\n\n // Test alternative data formats\n testCases.push(...makeAltDataTestCases(sampleProps, propTypes));\n\n for (const propName in Layer.defaultProps) {\n if (!(propName in sampleProps)) {\n // Do not override user provided props - they may be layer-specific\n const newTestCase =\n makeAltPropTestCase({propName, propTypes, defaultProps, sampleProps, assert}) || [];\n testCases.push(...newTestCase);\n }\n }\n\n testCases.forEach(testCase => {\n testCase.title = wrapTestCaseTitle(testCase.title);\n const beforeFunc = testCase.onBeforeUpdate || noop;\n const afterFunc = testCase.onAfterUpdate || noop;\n testCase.onBeforeUpdate = params => {\n // Generated callback\n beforeFunc(params);\n // User callback\n onBeforeUpdate(params);\n };\n testCase.onAfterUpdate = params => {\n // Generated callback\n afterFunc(params);\n // User callback\n onAfterUpdate(params);\n\n // Default assert\n if (runDefaultAsserts) {\n if (params.layer.isComposite) {\n const {data} = params.layer.props;\n if (data && typeof data === 'object' && count(data)) {\n assert(params.subLayers.length, 'Layer should have sublayers');\n }\n } else {\n assert(params.layer.getModels().length, 'Layer should have models');\n }\n }\n };\n });\n\n return testCases;\n}\n\nfunction makeAltPropTestCase({propName, propTypes, defaultProps, sampleProps, assert}) {\n const newProps = {...sampleProps};\n const propDef = propTypes[propName];\n\n if (!propDef) {\n return null;\n }\n\n switch (propDef.type) {\n case 'boolean':\n newProps[propName] = !defaultProps[propName];\n return [\n {\n title: `${propName}: ${String(newProps[propName])}`,\n props: newProps\n }\n ];\n\n case 'number':\n if ('max' in propDef) {\n newProps[propName] = propDef.max;\n } else if ('min' in propDef) {\n newProps[propName] = propDef.min;\n } else {\n newProps[propName] = defaultProps[propName] + 1;\n }\n return [\n {\n title: `${propName}: ${String(newProps[propName])}`,\n props: newProps\n }\n ];\n\n case 'accessor': {\n if (typeof defaultProps[propName] === 'function') {\n return null;\n }\n let callCount = 0;\n newProps[propName] = () => {\n callCount++;\n return defaultProps[propName];\n };\n newProps.updateTriggers = {\n [propName]: 'function'\n };\n const onBeforeUpdate = () => (callCount = 0);\n const onAfterUpdate = () => assert(callCount > 0, 'accessor function is called');\n\n return [\n {\n title: `${propName}: () => ${defaultProps[propName]}`,\n props: newProps,\n onBeforeUpdate,\n onAfterUpdate\n },\n {\n title: `${propName}: updateTrigger`,\n updateProps: {\n updateTriggers: {\n [propName]: 'function+trigger'\n }\n },\n onBeforeUpdate,\n onAfterUpdate\n }\n ];\n }\n\n default:\n return null;\n }\n}\n\nfunction makeAltDataTestCases(props, propTypes) {\n const originalData = props.data;\n if (!Array.isArray(originalData)) {\n return [];\n }\n // partial update\n const partialUpdateProps = {\n data: originalData.slice(),\n _dataDiff: () => [{startRow: 0, endRow: 2}]\n };\n // data should support any iterable\n const genIterableProps = {\n data: new Set(originalData),\n _dataDiff: null\n };\n // data in non-iterable form\n const nonIterableProps = {\n data: {\n length: originalData.length\n }\n };\n for (const propName in props) {\n if (propTypes[propName].type === 'accessor') {\n nonIterableProps[propName] = (_, info) => props[propName](originalData[info.index], info);\n }\n }\n\n return [\n {\n title: 'Partial update',\n updateProps: partialUpdateProps\n },\n {\n title: 'Generic iterable data',\n updateProps: genIterableProps\n },\n {\n title: 'non-iterable data',\n updateProps: nonIterableProps\n }\n ];\n}\n"],"file":"generate-layer-tests.js"}
|
package/dist/es5/index.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
Object.defineProperty(exports, "toLowPrecision", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function get() {
|
|
11
|
-
return _precision.toLowPrecision;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(exports, "gl", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function get() {
|
|
17
|
-
return _setupGl.gl;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(exports, "device", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function get() {
|
|
23
|
-
return _setupGl.device;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(exports, "testLayer", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function get() {
|
|
29
|
-
return _lifecycleTest.testLayer;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(exports, "testLayerAsync", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function get() {
|
|
35
|
-
return _lifecycleTest.testLayerAsync;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(exports, "testInitializeLayer", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function get() {
|
|
41
|
-
return _lifecycleTest.testInitializeLayer;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(exports, "testInitializeLayerAsync", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function get() {
|
|
47
|
-
return _lifecycleTest.testInitializeLayerAsync;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
Object.defineProperty(exports, "generateLayerTests", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
get: function get() {
|
|
53
|
-
return _generateLayerTests.generateLayerTests;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
Object.defineProperty(exports, "TestRunner", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function get() {
|
|
59
|
-
return _testRunner.default;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(exports, "SnapshotTestRunner", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function get() {
|
|
65
|
-
return _snapshotTestRunner.default;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(exports, "InteractionTestRunner", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function get() {
|
|
71
|
-
return _interactionTestRunner.default;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
var _precision = require("./utils/precision");
|
|
76
|
-
|
|
77
|
-
var _setupGl = require("./utils/setup-gl");
|
|
78
|
-
|
|
79
|
-
var _lifecycleTest = require("./lifecycle-test");
|
|
80
|
-
|
|
81
|
-
var _generateLayerTests = require("./generate-layer-tests");
|
|
82
|
-
|
|
83
|
-
var _testRunner = _interopRequireDefault(require("./test-runner"));
|
|
84
|
-
|
|
85
|
-
var _snapshotTestRunner = _interopRequireDefault(require("./snapshot-test-runner"));
|
|
86
|
-
|
|
87
|
-
var _interactionTestRunner = _interopRequireDefault(require("./interaction-test-runner"));
|
|
88
|
-
//# sourceMappingURL=index.js.map
|
package/dist/es5/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAGA;;AAMA;;AAGA;;AAGA;;AAEA","sourcesContent":["export {toLowPrecision} from './utils/precision';\nexport {gl, device} from './utils/setup-gl';\n\n// Utilities for update tests (lifecycle tests)\nexport {\n testLayer,\n testLayerAsync,\n testInitializeLayer,\n testInitializeLayerAsync\n} from './lifecycle-test';\nexport {generateLayerTests} from './generate-layer-tests';\n\n// Basic utility for rendering multiple scenes (could go into \"deck.gl/core\")\nexport {default as TestRunner} from './test-runner';\n\n// A utility that renders a list of scenes and compares against golden images\nexport {default as SnapshotTestRunner} from './snapshot-test-runner';\n// A utility that emulates input events\nexport {default as InteractionTestRunner} from './interaction-test-runner';\n"],"file":"index.js"}
|