@deck.gl/test-utils 8.7.0-alpha.3 → 8.7.0-beta.1

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.
@@ -1,12 +1,24 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.generateLayerTests = generateLayerTests;
7
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
+
8
16
  var _core = require("@deck.gl/core");
9
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
+
10
22
  function noop() {}
11
23
 
12
24
  function defaultAssert(condition, comment) {
@@ -15,21 +27,25 @@ function defaultAssert(condition, comment) {
15
27
  }
16
28
  }
17
29
 
18
- function generateLayerTests({
19
- Layer,
20
- sampleProps = {},
21
- assert = defaultAssert,
22
- onBeforeUpdate = noop,
23
- onAfterUpdate = noop,
24
- runDefaultAsserts = true
25
- }) {
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;
26
42
  assert(Layer.layerName, 'Layer should have display name');
27
43
 
28
44
  function wrapTestCaseTitle(title) {
29
45
  return "".concat(Layer.layerName, "#").concat(title);
30
46
  }
31
47
 
32
- const testCases = [{
48
+ var testCases = [{
33
49
  title: 'Empty props',
34
50
  props: {}
35
51
  }, {
@@ -48,46 +64,42 @@ function generateLayerTests({
48
64
  assert(false, "Construct ".concat(Layer.layerName, " throws: ").concat(error.message));
49
65
  }
50
66
 
51
- const {
52
- _propTypes: propTypes,
53
- _mergedDefaultProps: defaultProps
54
- } = Layer;
55
- testCases.push(...makeAltDataTestCases(sampleProps, propTypes));
67
+ var propTypes = Layer._propTypes,
68
+ defaultProps = Layer._mergedDefaultProps;
69
+ testCases.push.apply(testCases, (0, _toConsumableArray2.default)(makeAltDataTestCases(sampleProps, propTypes)));
56
70
 
57
- for (const propName in Layer.defaultProps) {
71
+ for (var propName in Layer.defaultProps) {
58
72
  if (!(propName in sampleProps)) {
59
- const newTestCase = makeAltPropTestCase({
60
- propName,
61
- propTypes,
62
- defaultProps,
63
- sampleProps,
64
- assert
73
+ var newTestCase = makeAltPropTestCase({
74
+ propName: propName,
75
+ propTypes: propTypes,
76
+ defaultProps: defaultProps,
77
+ sampleProps: sampleProps,
78
+ assert: assert
65
79
  }) || [];
66
- testCases.push(...newTestCase);
80
+ testCases.push.apply(testCases, (0, _toConsumableArray2.default)(newTestCase));
67
81
  }
68
82
  }
69
83
 
70
- testCases.forEach(testCase => {
84
+ testCases.forEach(function (testCase) {
71
85
  testCase.title = wrapTestCaseTitle(testCase.title);
72
- const beforeFunc = testCase.onBeforeUpdate || noop;
73
- const afterFunc = testCase.onAfterUpdate || noop;
86
+ var beforeFunc = testCase.onBeforeUpdate || noop;
87
+ var afterFunc = testCase.onAfterUpdate || noop;
74
88
 
75
- testCase.onBeforeUpdate = params => {
89
+ testCase.onBeforeUpdate = function (params) {
76
90
  beforeFunc(params);
77
91
  onBeforeUpdate(params);
78
92
  };
79
93
 
80
- testCase.onAfterUpdate = params => {
94
+ testCase.onAfterUpdate = function (params) {
81
95
  afterFunc(params);
82
96
  onAfterUpdate(params);
83
97
 
84
98
  if (runDefaultAsserts) {
85
99
  if (params.layer.isComposite) {
86
- const {
87
- data
88
- } = params.layer.props;
100
+ var data = params.layer.props.data;
89
101
 
90
- if (data && typeof data === 'object' && (0, _core._count)(data)) {
102
+ if (data && (0, _typeof2.default)(data) === 'object' && (0, _core._count)(data)) {
91
103
  assert(params.subLayers.length, 'Layer should have sublayers');
92
104
  }
93
105
  } else {
@@ -99,16 +111,16 @@ function generateLayerTests({
99
111
  return testCases;
100
112
  }
101
113
 
102
- function makeAltPropTestCase({
103
- propName,
104
- propTypes,
105
- defaultProps,
106
- sampleProps,
107
- assert
108
- }) {
109
- const newProps = { ...sampleProps
110
- };
111
- const propDef = propTypes[propName];
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];
112
124
 
113
125
  if (!propDef) {
114
126
  return null;
@@ -142,35 +154,35 @@ function makeAltPropTestCase({
142
154
  return null;
143
155
  }
144
156
 
145
- let callCount = 0;
157
+ var callCount = 0;
146
158
 
147
- newProps[propName] = () => {
159
+ newProps[propName] = function () {
148
160
  callCount++;
149
161
  return defaultProps[propName];
150
162
  };
151
163
 
152
- newProps.updateTriggers = {
153
- [propName]: 'function'
154
- };
164
+ newProps.updateTriggers = (0, _defineProperty2.default)({}, propName, 'function');
155
165
 
156
- const onBeforeUpdate = () => callCount = 0;
166
+ var onBeforeUpdate = function onBeforeUpdate() {
167
+ return callCount = 0;
168
+ };
157
169
 
158
- const onAfterUpdate = () => assert(callCount > 0, 'accessor function is called');
170
+ var onAfterUpdate = function onAfterUpdate() {
171
+ return assert(callCount > 0, 'accessor function is called');
172
+ };
159
173
 
160
174
  return [{
161
175
  title: "".concat(propName, ": () => ").concat(defaultProps[propName]),
162
176
  props: newProps,
163
- onBeforeUpdate,
164
- onAfterUpdate
177
+ onBeforeUpdate: onBeforeUpdate,
178
+ onAfterUpdate: onAfterUpdate
165
179
  }, {
166
180
  title: "".concat(propName, ": updateTrigger"),
167
181
  updateProps: {
168
- updateTriggers: {
169
- [propName]: 'function+trigger'
170
- }
182
+ updateTriggers: (0, _defineProperty2.default)({}, propName, 'function+trigger')
171
183
  },
172
- onBeforeUpdate,
173
- onAfterUpdate
184
+ onBeforeUpdate: onBeforeUpdate,
185
+ onAfterUpdate: onAfterUpdate
174
186
  }];
175
187
  }
176
188
 
@@ -180,33 +192,41 @@ function makeAltPropTestCase({
180
192
  }
181
193
 
182
194
  function makeAltDataTestCases(props, propTypes) {
183
- const originalData = props.data;
195
+ var originalData = props.data;
184
196
 
185
197
  if (!Array.isArray(originalData)) {
186
198
  return [];
187
199
  }
188
200
 
189
- const partialUpdateProps = {
201
+ var partialUpdateProps = {
190
202
  data: originalData.slice(),
191
- _dataDiff: () => [{
192
- startRow: 0,
193
- endRow: 2
194
- }]
203
+ _dataDiff: function _dataDiff() {
204
+ return [{
205
+ startRow: 0,
206
+ endRow: 2
207
+ }];
208
+ }
195
209
  };
196
- const genIterableProps = {
210
+ var genIterableProps = {
197
211
  data: new Set(originalData),
198
212
  _dataDiff: null
199
213
  };
200
- const nonIterableProps = {
214
+ var nonIterableProps = {
201
215
  data: {
202
216
  length: originalData.length
203
217
  }
204
218
  };
205
219
 
206
- for (const propName in props) {
220
+ var _loop = function _loop(propName) {
207
221
  if (propTypes[propName].type === 'accessor') {
208
- nonIterableProps[propName] = (_, info) => props[propName](originalData[info.index], info);
222
+ nonIterableProps[propName] = function (_, info) {
223
+ return props[propName](originalData[info.index], info);
224
+ };
209
225
  }
226
+ };
227
+
228
+ for (var propName in props) {
229
+ _loop(propName);
210
230
  }
211
231
 
212
232
  return [{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/generate-layer-tests.js"],"names":["noop","defaultAssert","condition","comment","Error","generateLayerTests","Layer","sampleProps","assert","onBeforeUpdate","onAfterUpdate","runDefaultAsserts","layerName","wrapTestCaseTitle","title","testCases","props","updateProps","data","error","message","_propTypes","propTypes","_mergedDefaultProps","defaultProps","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;;AAEA,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,CAA4B;AACjCC,EAAAA,KADiC;AAEjCC,EAAAA,WAAW,GAAG,EAFmB;AAGjCC,EAAAA,MAAM,GAAGP,aAHwB;AAIjCQ,EAAAA,cAAc,GAAGT,IAJgB;AA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,YAAY,CAACV;AADjB;AADiB,GAAzB;;AAKA,OAAK,MAAMX,QAAX,IAAuBX,KAAvB,EAA8B;AAC5B,QAAIM,SAAS,CAACK,QAAD,CAAT,CAAoBe,IAApB,KAA6B,UAAjC,EAA6C;AAC3CgB,MAAAA,gBAAgB,CAAC/B,QAAD,CAAhB,GAA6B,CAACgC,CAAD,EAAIC,IAAJ,KAAa5C,KAAK,CAACW,QAAD,CAAL,CAAgBqB,YAAY,CAACY,IAAI,CAACC,KAAN,CAA5B,EAA0CD,IAA1C,CAA1C;AACD;AACF;;AAED,SAAO,CACL;AACE9C,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\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"}
1
+ {"version":3,"sources":["../../src/generate-layer-tests.js"],"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;;;;;;AAEA,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,QANDA,KAMC;AAAA,8BALDC,WAKC;AAAA,MALDA,WAKC,iCALa,EAKb;AAAA,yBAJDC,MAIC;AAAA,MAJDA,MAIC,4BAJQP,aAIR;AAAA,iCAHDQ,cAGC;AAAA,MAHDA,cAGC,oCAHgBT,IAGhB;AAAA,gCAFDU,aAEC;AAAA,MAFDA,aAEC,mCAFeV,IAEf;AAAA,mCADDW,iBACC;AAAA,MADDA,iBACC,sCADmB,IACnB;AACDH,EAAAA,MAAM,CAACF,KAAK,CAACM,SAAP,EAAkB,gCAAlB,CAAN;;AAEA,WAASC,iBAAT,CAA2BC,KAA3B,EAAkC;AAChC,qBAAUR,KAAK,CAACM,SAAhB,cAA6BE,KAA7B;AACD;;AAED,MAAMC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AAAA,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\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 CHANGED
@@ -7,61 +7,61 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  Object.defineProperty(exports, "toLowPrecision", {
9
9
  enumerable: true,
10
- get: function () {
10
+ get: function get() {
11
11
  return _precision.toLowPrecision;
12
12
  }
13
13
  });
14
14
  Object.defineProperty(exports, "gl", {
15
15
  enumerable: true,
16
- get: function () {
16
+ get: function get() {
17
17
  return _setupGl.default;
18
18
  }
19
19
  });
20
20
  Object.defineProperty(exports, "testLayer", {
21
21
  enumerable: true,
22
- get: function () {
22
+ get: function get() {
23
23
  return _lifecycleTest.testLayer;
24
24
  }
25
25
  });
26
26
  Object.defineProperty(exports, "testLayerAsync", {
27
27
  enumerable: true,
28
- get: function () {
28
+ get: function get() {
29
29
  return _lifecycleTest.testLayerAsync;
30
30
  }
31
31
  });
32
32
  Object.defineProperty(exports, "testInitializeLayer", {
33
33
  enumerable: true,
34
- get: function () {
34
+ get: function get() {
35
35
  return _lifecycleTest.testInitializeLayer;
36
36
  }
37
37
  });
38
38
  Object.defineProperty(exports, "testInitializeLayerAsync", {
39
39
  enumerable: true,
40
- get: function () {
40
+ get: function get() {
41
41
  return _lifecycleTest.testInitializeLayerAsync;
42
42
  }
43
43
  });
44
44
  Object.defineProperty(exports, "generateLayerTests", {
45
45
  enumerable: true,
46
- get: function () {
46
+ get: function get() {
47
47
  return _generateLayerTests.generateLayerTests;
48
48
  }
49
49
  });
50
50
  Object.defineProperty(exports, "TestRunner", {
51
51
  enumerable: true,
52
- get: function () {
52
+ get: function get() {
53
53
  return _testRunner.default;
54
54
  }
55
55
  });
56
56
  Object.defineProperty(exports, "SnapshotTestRunner", {
57
57
  enumerable: true,
58
- get: function () {
58
+ get: function get() {
59
59
  return _snapshotTestRunner.default;
60
60
  }
61
61
  });
62
62
  Object.defineProperty(exports, "InteractionTestRunner", {
63
63
  enumerable: true,
64
- get: function () {
64
+ get: function get() {
65
65
  return _interactionTestRunner.default;
66
66
  }
67
67
  });
@@ -7,58 +7,113 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
+
16
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
+
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
+
10
20
  var _testRunner = _interopRequireDefault(require("./test-runner"));
11
21
 
12
- const DEFAULT_TEST_CASE = {
22
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
23
+
24
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
+
26
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
27
+
28
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
29
+
30
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
31
+
32
+ var DEFAULT_TEST_CASE = {
13
33
  name: 'Unnamed interaction test',
14
34
  events: [],
15
- onBeforeEvents: ({
16
- deck
17
- }) => {},
18
- onAfterEvents: ({
19
- deck,
20
- layers,
21
- context
22
- }) => {}
35
+ onBeforeEvents: function onBeforeEvents(_ref) {
36
+ var deck = _ref.deck;
37
+ },
38
+ onAfterEvents: function onAfterEvents(_ref2) {
39
+ var deck = _ref2.deck,
40
+ layers = _ref2.layers,
41
+ context = _ref2.context;
42
+ }
23
43
  };
24
44
 
25
45
  function sleep(timeout) {
26
- return new Promise(resolve => window.setTimeout(resolve, timeout));
46
+ return new Promise(function (resolve) {
47
+ return window.setTimeout(resolve, timeout);
48
+ });
27
49
  }
28
50
 
29
- class InteractionTestRunner extends _testRunner.default {
30
- get defaultTestCase() {
31
- return DEFAULT_TEST_CASE;
51
+ var InteractionTestRunner = function (_TestRunner) {
52
+ (0, _inherits2.default)(InteractionTestRunner, _TestRunner);
53
+
54
+ var _super = _createSuper(InteractionTestRunner);
55
+
56
+ function InteractionTestRunner() {
57
+ (0, _classCallCheck2.default)(this, InteractionTestRunner);
58
+ return _super.apply(this, arguments);
32
59
  }
33
60
 
34
- runTestCase(testCase, onDone) {
35
- testCase.context = testCase.onBeforeEvents({
36
- deck: this.deck
37
- });
38
- let promise = Promise.resolve();
39
-
40
- for (const event of testCase.events) {
41
- if (event.wait) {
42
- promise = promise.then(() => sleep(event.wait));
43
- } else {
44
- promise = promise.then(() => window.browserTestDriver_emulateInput(event));
45
- }
61
+ (0, _createClass2.default)(InteractionTestRunner, [{
62
+ key: "defaultTestCase",
63
+ get: function get() {
64
+ return DEFAULT_TEST_CASE;
46
65
  }
66
+ }, {
67
+ key: "runTestCase",
68
+ value: function runTestCase(testCase, onDone) {
69
+ testCase.context = testCase.onBeforeEvents({
70
+ deck: this.deck
71
+ });
72
+ var promise = Promise.resolve();
47
73
 
48
- return promise.then(onDone);
49
- }
74
+ var _iterator = _createForOfIteratorHelper(testCase.events),
75
+ _step;
50
76
 
51
- assert(testCase) {
52
- testCase.onAfterEvents({
53
- deck: this.deck,
54
- layers: this.deck.layerManager.getLayers(),
55
- context: testCase.context
56
- });
77
+ try {
78
+ var _loop = function _loop() {
79
+ var event = _step.value;
57
80
 
58
- this._next();
59
- }
81
+ if (event.wait) {
82
+ promise = promise.then(function () {
83
+ return sleep(event.wait);
84
+ });
85
+ } else {
86
+ promise = promise.then(function () {
87
+ return window.browserTestDriver_emulateInput(event);
88
+ });
89
+ }
90
+ };
60
91
 
61
- }
92
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
93
+ _loop();
94
+ }
95
+ } catch (err) {
96
+ _iterator.e(err);
97
+ } finally {
98
+ _iterator.f();
99
+ }
100
+
101
+ return promise.then(onDone);
102
+ }
103
+ }, {
104
+ key: "assert",
105
+ value: function assert(testCase) {
106
+ testCase.onAfterEvents({
107
+ deck: this.deck,
108
+ layers: this.deck.layerManager.getLayers(),
109
+ context: testCase.context
110
+ });
111
+
112
+ this._next();
113
+ }
114
+ }]);
115
+ return InteractionTestRunner;
116
+ }(_testRunner.default);
62
117
 
63
118
  exports.default = InteractionTestRunner;
64
119
  //# sourceMappingURL=interaction-test-runner.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/interaction-test-runner.js"],"names":["DEFAULT_TEST_CASE","name","events","onBeforeEvents","deck","onAfterEvents","layers","context","sleep","timeout","Promise","resolve","window","setTimeout","InteractionTestRunner","TestRunner","defaultTestCase","runTestCase","testCase","onDone","promise","event","wait","then","browserTestDriver_emulateInput","assert","layerManager","getLayers","_next"],"mappings":";;;;;;;;;AAqBA;;AAEA,MAAMA,iBAAiB,GAAG;AACxBC,EAAAA,IAAI,EAAE,0BADkB;AAExBC,EAAAA,MAAM,EAAE,EAFgB;AAGxBC,EAAAA,cAAc,EAAE,CAAC;AAACC,IAAAA;AAAD,GAAD,KAAY,CAAE,CAHN;AAIxBC,EAAAA,aAAa,EAAE,CAAC;AAACD,IAAAA,IAAD;AAAOE,IAAAA,MAAP;AAAeC,IAAAA;AAAf,GAAD,KAA6B,CAAE;AAJtB,CAA1B;;AAOA,SAASC,KAAT,CAAeC,OAAf,EAAwB;AACtB,SAAO,IAAIC,OAAJ,CAAYC,OAAO,IAAIC,MAAM,CAACC,UAAP,CAAkBF,OAAlB,EAA2BF,OAA3B,CAAvB,CAAP;AACD;;AAEc,MAAMK,qBAAN,SAAoCC,mBAApC,CAA+C;AACzC,MAAfC,eAAe,GAAG;AACpB,WAAOhB,iBAAP;AACD;;AAIDiB,EAAAA,WAAW,CAACC,QAAD,EAAWC,MAAX,EAAmB;AAC5BD,IAAAA,QAAQ,CAACX,OAAT,GAAmBW,QAAQ,CAACf,cAAT,CAAwB;AACzCC,MAAAA,IAAI,EAAE,KAAKA;AAD8B,KAAxB,CAAnB;AAIA,QAAIgB,OAAO,GAAGV,OAAO,CAACC,OAAR,EAAd;;AACA,SAAK,MAAMU,KAAX,IAAoBH,QAAQ,CAAChB,MAA7B,EAAqC;AACnC,UAAImB,KAAK,CAACC,IAAV,EAAgB;AACdF,QAAAA,OAAO,GAAGA,OAAO,CAACG,IAAR,CAAa,MAAMf,KAAK,CAACa,KAAK,CAACC,IAAP,CAAxB,CAAV;AACD,OAFD,MAEO;AACLF,QAAAA,OAAO,GAAGA,OAAO,CAACG,IAAR,CAAa,MAAMX,MAAM,CAACY,8BAAP,CAAsCH,KAAtC,CAAnB,CAAV;AACD;AACF;;AACD,WAAOD,OAAO,CAACG,IAAR,CAAaJ,MAAb,CAAP;AACD;;AAEDM,EAAAA,MAAM,CAACP,QAAD,EAAW;AACfA,IAAAA,QAAQ,CAACb,aAAT,CAAuB;AACrBD,MAAAA,IAAI,EAAE,KAAKA,IADU;AAErBE,MAAAA,MAAM,EAAE,KAAKF,IAAL,CAAUsB,YAAV,CAAuBC,SAAvB,EAFa;AAGrBpB,MAAAA,OAAO,EAAEW,QAAQ,CAACX;AAHG,KAAvB;;AAKA,SAAKqB,KAAL;AACD;;AA9B2D","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.\n\n/* global window */\nimport TestRunner from './test-runner';\n\nconst DEFAULT_TEST_CASE = {\n name: 'Unnamed interaction test',\n events: [],\n onBeforeEvents: ({deck}) => {},\n onAfterEvents: ({deck, layers, context}) => {}\n};\n\nfunction sleep(timeout) {\n return new Promise(resolve => window.setTimeout(resolve, timeout));\n}\n\nexport default class InteractionTestRunner extends TestRunner {\n get defaultTestCase() {\n return DEFAULT_TEST_CASE;\n }\n\n // chain events\n // TODO - switch to async/await\n runTestCase(testCase, onDone) {\n testCase.context = testCase.onBeforeEvents({\n deck: this.deck\n });\n\n let promise = Promise.resolve();\n for (const event of testCase.events) {\n if (event.wait) {\n promise = promise.then(() => sleep(event.wait));\n } else {\n promise = promise.then(() => window.browserTestDriver_emulateInput(event));\n }\n }\n return promise.then(onDone);\n }\n\n assert(testCase) {\n testCase.onAfterEvents({\n deck: this.deck,\n layers: this.deck.layerManager.getLayers(),\n context: testCase.context\n });\n this._next();\n }\n}\n"],"file":"interaction-test-runner.js"}
1
+ {"version":3,"sources":["../../src/interaction-test-runner.js"],"names":["DEFAULT_TEST_CASE","name","events","onBeforeEvents","deck","onAfterEvents","layers","context","sleep","timeout","Promise","resolve","window","setTimeout","InteractionTestRunner","testCase","onDone","promise","event","wait","then","browserTestDriver_emulateInput","layerManager","getLayers","_next","TestRunner"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA;;;;;;;;;;;;AAEA,IAAMA,iBAAiB,GAAG;AACxBC,EAAAA,IAAI,EAAE,0BADkB;AAExBC,EAAAA,MAAM,EAAE,EAFgB;AAGxBC,EAAAA,cAAc,EAAE,8BAAY;AAAA,QAAVC,IAAU,QAAVA,IAAU;AAAE,GAHN;AAIxBC,EAAAA,aAAa,EAA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AAA,MAAM,EAAE,KAAKF,IAAL,CAAUkB,YAAV,CAAuBC,SAAvB,EAFa;AAGrBhB,QAAAA,OAAO,EAAEQ,QAAQ,CAACR;AAHG,OAAvB;;AAKA,WAAKiB,KAAL;AACD;;;EA9BgDC,mB","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.\n\n/* global window */\nimport TestRunner from './test-runner';\n\nconst DEFAULT_TEST_CASE = {\n name: 'Unnamed interaction test',\n events: [],\n onBeforeEvents: ({deck}) => {},\n onAfterEvents: ({deck, layers, context}) => {}\n};\n\nfunction sleep(timeout) {\n return new Promise(resolve => window.setTimeout(resolve, timeout));\n}\n\nexport default class InteractionTestRunner extends TestRunner {\n get defaultTestCase() {\n return DEFAULT_TEST_CASE;\n }\n\n // chain events\n // TODO - switch to async/await\n runTestCase(testCase, onDone) {\n testCase.context = testCase.onBeforeEvents({\n deck: this.deck\n });\n\n let promise = Promise.resolve();\n for (const event of testCase.events) {\n if (event.wait) {\n promise = promise.then(() => sleep(event.wait));\n } else {\n promise = promise.then(() => window.browserTestDriver_emulateInput(event));\n }\n }\n return promise.then(onDone);\n }\n\n assert(testCase) {\n testCase.onAfterEvents({\n deck: this.deck,\n layers: this.deck.layerManager.getLayers(),\n context: testCase.context\n });\n this._next();\n }\n}\n"],"file":"interaction-test-runner.js"}