@sasjs/cli 3.6.5 → 3.7.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,2 +1,4 @@
1
1
  import { Target } from '@sasjs/utils';
2
- export declare function runTest(target: Target, testRegExps?: string[], outDirectory?: string, flowSourcePath?: string): Promise<undefined>;
2
+ import SASjs from '@sasjs/adapter/node';
3
+ export declare function runTest(target: Target, testRegExps?: string[], outDirectory?: string, flowSourcePath?: string, sasjs?: SASjs): Promise<undefined>;
4
+ export declare const getTestUrl: (target: Target, jobLocation: string) => string;
@@ -75,7 +75,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
75
75
  return (mod && mod.__esModule) ? mod : { "default": mod };
76
76
  };
77
77
  Object.defineProperty(exports, "__esModule", { value: true });
78
- exports.runTest = void 0;
78
+ exports.getTestUrl = exports.runTest = void 0;
79
79
  var saveOutput_1 = require("./internal/saveOutput");
80
80
  var types_1 = require("../../types");
81
81
  var file_1 = require("../../utils/file");
@@ -86,11 +86,11 @@ var node_1 = __importDefault(require("@sasjs/adapter/node"));
86
86
  var path_1 = __importDefault(require("path"));
87
87
  var chalk_1 = __importDefault(require("chalk"));
88
88
  var utils_2 = require("../../utils/utils");
89
- function runTest(target, testRegExps, outDirectory, flowSourcePath) {
89
+ function runTest(target, testRegExps, outDirectory, flowSourcePath, sasjs) {
90
90
  var _a, _b;
91
91
  if (testRegExps === void 0) { testRegExps = []; }
92
92
  return __awaiter(this, void 0, void 0, function () {
93
- var testFlowData, testFlow, flow, sasjs, authConfig, username, password, sas9CredentialsError, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _c, csvData, csvPath, coverageReportPath, resultTable, testsCount, passedTestsCount, testsWithResultsCount;
93
+ var testFlowData, testFlow, flow, authConfig, username, password, sas9CredentialsError, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _c, csvData, csvPath, coverageReportPath, resultTable, testsCount, passedTestsCount, testsWithResultsCount;
94
94
  var _this = this;
95
95
  return __generator(this, function (_d) {
96
96
  switch (_d.label) {
@@ -146,15 +146,17 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
146
146
  })), false);
147
147
  if (testFlow.testTearDown)
148
148
  flow.push(testFlow.testTearDown);
149
- sasjs = new node_1.default({
150
- serverUrl: target.serverUrl,
151
- httpsAgentOptions: target.httpsAgentOptions,
152
- appLoc: target.appLoc,
153
- serverType: target.serverType,
154
- debug: true,
155
- contextName: target.contextName,
156
- useComputeApi: false
157
- });
149
+ sasjs =
150
+ sasjs ||
151
+ new node_1.default({
152
+ serverUrl: target.serverUrl,
153
+ httpsAgentOptions: target.httpsAgentOptions,
154
+ appLoc: target.appLoc,
155
+ serverType: target.serverType,
156
+ debug: true,
157
+ contextName: target.contextName,
158
+ useComputeApi: false
159
+ });
158
160
  if (!(target.serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 3];
159
161
  return [4 /*yield*/, (0, config_1.getAuthConfig)(target)];
160
162
  case 2:
@@ -188,7 +190,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
188
190
  }
189
191
  };
190
192
  return [4 /*yield*/, (0, utils_1.asyncForEach)(flow, function (test) { return __awaiter(_this, void 0, void 0, function () {
191
- var sasJobLocation, testTarget, testId, testUrl, printTestUrl;
193
+ var sasJobLocation, testTarget, testId, testUrl, printTestUrl, sasjsResponse, webout, testResults, existingTestTarget;
192
194
  var _this = this;
193
195
  return __generator(this, function (_a) {
194
196
  switch (_a.label) {
@@ -202,120 +204,163 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
202
204
  .pop()
203
205
  .replace(/(.test)?(.\d+)?(.sas)?$/i, '');
204
206
  testId = (0, utils_1.uuidv4)();
205
- testUrl = "".concat(target.serverUrl, "/").concat(target.serverType === utils_1.ServerType.SasViya
206
- ? 'SASJobExecution'
207
- : 'SASStoredProcess', "/?_program=").concat(sasJobLocation, "&_debug=2477");
207
+ testUrl = (0, exports.getTestUrl)(target, sasJobLocation);
208
208
  if (target.contextName) {
209
209
  testUrl = "".concat(testUrl, "&_contextName=").concat(encodeURIComponent(target.contextName));
210
210
  }
211
211
  printTestUrl = function () { return process.logger.info("Test URL: ".concat(testUrl)); };
212
212
  printTestUrl();
213
- return [4 /*yield*/, sasjs
214
- .request(sasJobLocation, {}, { username: username, password: password }, function () {
215
- (0, displayResult_1.displayError)(null, 'Login callback called. Request failed.');
216
- }, authConfig, ['log'])
217
- .then(function (res) { return __awaiter(_this, void 0, void 0, function () {
218
- var lineBreak, existingTestTarget, existingTestTarget;
219
- var _a, _b;
220
- return __generator(this, function (_c) {
221
- switch (_c.label) {
222
- case 0:
223
- lineBreak = true;
224
- if (!res.result) {
225
- (0, displayResult_1.displayError)({}, "Job did not return a response, to debug click ".concat(testUrl));
226
- printCodeExample();
227
- lineBreak = false;
228
- existingTestTarget = result.sasjs_test_meta.find(function (testResult) {
229
- return testResult.test_target === testTarget;
230
- });
231
- if (existingTestTarget) {
232
- existingTestTarget.results.push({
233
- test_loc: test,
234
- sasjs_test_id: testId,
235
- result: types_1.TestResultStatus.notProvided,
236
- test_url: testUrl
237
- });
238
- }
239
- else {
240
- result.sasjs_test_meta.push({
241
- test_target: testTarget,
242
- results: [
243
- {
244
- test_loc: test,
245
- sasjs_test_id: testId,
246
- result: types_1.TestResultStatus.notProvided,
247
- test_url: testUrl
248
- }
249
- ]
250
- });
251
- }
213
+ if (!(target.serverType === utils_1.ServerType.Sasjs)) return [3 /*break*/, 2];
214
+ return [4 /*yield*/, sasjs.executeJobSASjs({
215
+ _program: sasJobLocation,
216
+ _debug: 131
217
+ })];
218
+ case 1:
219
+ sasjsResponse = _a.sent();
220
+ if (sasjsResponse._webout) {
221
+ webout = void 0;
222
+ try {
223
+ webout = JSON.parse(sasjsResponse._webout);
224
+ }
225
+ catch (error) {
226
+ return [2 /*return*/, Promise.reject("SASjs Server responded with invalid json")];
227
+ }
228
+ testResults = webout.test_results;
229
+ if (testResults) {
230
+ existingTestTarget = result.sasjs_test_meta.find(function (testResult) {
231
+ return testResult.test_target === testTarget;
232
+ });
233
+ if (existingTestTarget) {
234
+ existingTestTarget.results.push({
235
+ test_loc: test,
236
+ sasjs_test_id: testId,
237
+ result: testResults,
238
+ test_url: testUrl
239
+ });
240
+ }
241
+ else {
242
+ result.sasjs_test_meta.push({
243
+ test_target: testTarget,
244
+ results: [
245
+ {
246
+ test_loc: test,
247
+ sasjs_test_id: testId,
248
+ result: testResults,
249
+ test_url: testUrl
252
250
  }
253
- if (!((_a = res.result) === null || _a === void 0 ? void 0 : _a.test_results))
254
- lineBreak = false;
255
- if (!res.log) return [3 /*break*/, 2];
256
- return [4 /*yield*/, (0, saveOutput_1.saveLog)(outDirectory, test, res.log, lineBreak)];
257
- case 1:
258
- _c.sent();
259
- _c.label = 2;
260
- case 2:
261
- if ((_b = res.result) === null || _b === void 0 ? void 0 : _b.test_results) {
262
- existingTestTarget = result.sasjs_test_meta.find(function (testResult) {
263
- return testResult.test_target === testTarget;
251
+ ]
252
+ });
253
+ }
254
+ }
255
+ }
256
+ return [3 /*break*/, 4];
257
+ case 2: return [4 /*yield*/, sasjs
258
+ .request(sasJobLocation, {}, { username: username, password: password }, function () {
259
+ (0, displayResult_1.displayError)(null, 'Login callback called. Request failed.');
260
+ }, authConfig, ['log'])
261
+ .then(function (res) { return __awaiter(_this, void 0, void 0, function () {
262
+ var lineBreak, existingTestTarget, existingTestTarget;
263
+ var _a, _b;
264
+ return __generator(this, function (_c) {
265
+ switch (_c.label) {
266
+ case 0:
267
+ lineBreak = true;
268
+ if (!res.result) {
269
+ (0, displayResult_1.displayError)({}, "Job did not return a response, to debug click ".concat(testUrl));
270
+ printCodeExample();
271
+ lineBreak = false;
272
+ existingTestTarget = result.sasjs_test_meta.find(function (testResult) {
273
+ return testResult.test_target === testTarget;
274
+ });
275
+ if (existingTestTarget) {
276
+ existingTestTarget.results.push({
277
+ test_loc: test,
278
+ sasjs_test_id: testId,
279
+ result: types_1.TestResultStatus.notProvided,
280
+ test_url: testUrl
264
281
  });
265
- if (existingTestTarget) {
266
- existingTestTarget.results.push({
267
- test_loc: test,
268
- sasjs_test_id: testId,
269
- result: res.result.test_results,
270
- test_url: testUrl
271
- });
272
- }
273
- else {
274
- result.sasjs_test_meta.push({
275
- test_target: testTarget,
276
- results: [
277
- {
278
- test_loc: test,
279
- sasjs_test_id: testId,
280
- result: res.result.test_results,
281
- test_url: testUrl
282
- }
283
- ]
284
- });
285
- }
286
282
  }
287
283
  else {
288
- (0, displayResult_1.displayError)({}, "'test_results' not found in server response, to debug click ".concat(testUrl));
289
- printCodeExample();
284
+ result.sasjs_test_meta.push({
285
+ test_target: testTarget,
286
+ results: [
287
+ {
288
+ test_loc: test,
289
+ sasjs_test_id: testId,
290
+ result: types_1.TestResultStatus.notProvided,
291
+ test_url: testUrl
292
+ }
293
+ ]
294
+ });
290
295
  }
291
- return [2 /*return*/];
292
- }
293
- });
294
- }); })
295
- .catch(function (err) { return __awaiter(_this, void 0, void 0, function () {
296
- var _a, _b;
297
- return __generator(this, function (_c) {
298
- switch (_c.label) {
299
- case 0:
300
- printTestUrl();
301
- if (err && err.errorCode === 404) {
302
- (0, utils_2.displaySasjsRunnerError)(username);
296
+ }
297
+ if (!((_a = res.result) === null || _a === void 0 ? void 0 : _a.test_results))
298
+ lineBreak = false;
299
+ if (!res.log) return [3 /*break*/, 2];
300
+ return [4 /*yield*/, (0, saveOutput_1.saveLog)(outDirectory, test, res.log, lineBreak)];
301
+ case 1:
302
+ _c.sent();
303
+ _c.label = 2;
304
+ case 2:
305
+ if ((_b = res.result) === null || _b === void 0 ? void 0 : _b.test_results) {
306
+ existingTestTarget = result.sasjs_test_meta.find(function (testResult) {
307
+ return testResult.test_target === testTarget;
308
+ });
309
+ if (existingTestTarget) {
310
+ existingTestTarget.results.push({
311
+ test_loc: test,
312
+ sasjs_test_id: testId,
313
+ result: res.result.test_results,
314
+ test_url: testUrl
315
+ });
303
316
  }
304
317
  else {
305
- (0, displayResult_1.displayError)({}, "An error occurred while executing the request. Job location: ".concat(sasJobLocation));
318
+ result.sasjs_test_meta.push({
319
+ test_target: testTarget,
320
+ results: [
321
+ {
322
+ test_loc: test,
323
+ sasjs_test_id: testId,
324
+ result: res.result.test_results,
325
+ test_url: testUrl
326
+ }
327
+ ]
328
+ });
306
329
  }
307
- if (!((_b = (_a = err === null || err === void 0 ? void 0 : err.error) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.result)) return [3 /*break*/, 2];
308
- return [4 /*yield*/, (0, saveOutput_1.saveLog)(outDirectory, test, err.error.details.result)];
309
- case 1:
310
- _c.sent();
311
- _c.label = 2;
312
- case 2: return [2 /*return*/];
313
- }
314
- });
315
- }); })];
316
- case 1:
330
+ }
331
+ else {
332
+ (0, displayResult_1.displayError)({}, "'test_results' not found in server response, to debug click ".concat(testUrl));
333
+ printCodeExample();
334
+ }
335
+ return [2 /*return*/];
336
+ }
337
+ });
338
+ }); })
339
+ .catch(function (err) { return __awaiter(_this, void 0, void 0, function () {
340
+ var _a, _b;
341
+ return __generator(this, function (_c) {
342
+ switch (_c.label) {
343
+ case 0:
344
+ printTestUrl();
345
+ if (err && err.errorCode === 404) {
346
+ (0, utils_2.displaySasjsRunnerError)(username);
347
+ }
348
+ else {
349
+ (0, displayResult_1.displayError)({}, "An error occurred while executing the request. Job location: ".concat(sasJobLocation));
350
+ }
351
+ if (!((_b = (_a = err === null || err === void 0 ? void 0 : err.error) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.result)) return [3 /*break*/, 2];
352
+ return [4 /*yield*/, (0, saveOutput_1.saveLog)(outDirectory, test, err.error.details.result)];
353
+ case 1:
354
+ _c.sent();
355
+ _c.label = 2;
356
+ case 2: return [2 /*return*/];
357
+ }
358
+ });
359
+ }); })];
360
+ case 3:
317
361
  _a.sent();
318
- return [2 /*return*/];
362
+ _a.label = 4;
363
+ case 4: return [2 /*return*/];
319
364
  }
320
365
  });
321
366
  }); })];
@@ -367,3 +412,11 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
367
412
  });
368
413
  }
369
414
  exports.runTest = runTest;
415
+ var getTestUrl = function (target, jobLocation) {
416
+ return "".concat(target.serverUrl, "/").concat(target.serverType === utils_1.ServerType.SasViya
417
+ ? 'SASJobExecution'
418
+ : target.serverType === utils_1.ServerType.Sas9
419
+ ? 'SASStoredProcess'
420
+ : 'SASjsApi/stp/execute', "/?_program=").concat(jobLocation, "&_debug=2477");
421
+ };
422
+ exports.getTestUrl = getTestUrl;
@@ -1,5 +1,7 @@
1
1
  import { JSDOM } from 'jsdom';
2
2
  export declare const getScriptTags: (parsedHtml: JSDOM) => HTMLScriptElement[];
3
+ export declare const getStyleInPageTags: (parsedHtml: JSDOM) => HTMLStyleElement[];
3
4
  export declare const getStyleTags: (parsedHtml: JSDOM) => HTMLLinkElement[];
4
5
  export declare const getFaviconTags: (parsedHtml: JSDOM) => HTMLLinkElement[];
5
6
  export declare const getImgTags: (parsedHtml: JSDOM) => HTMLImageElement[];
7
+ export declare const getSourceTags: (parsedHtml: JSDOM) => HTMLSourceElement[];
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getImgTags = exports.getFaviconTags = exports.getStyleTags = exports.getScriptTags = void 0;
3
+ exports.getSourceTags = exports.getImgTags = exports.getFaviconTags = exports.getStyleTags = exports.getStyleInPageTags = exports.getScriptTags = void 0;
4
4
  var getScriptTags = function (parsedHtml) {
5
5
  return Array.from(parsedHtml.window.document.getElementsByTagName('script'));
6
6
  };
7
7
  exports.getScriptTags = getScriptTags;
8
+ var getStyleInPageTags = function (parsedHtml) {
9
+ return Array.from(parsedHtml.window.document.getElementsByTagName('style'));
10
+ };
11
+ exports.getStyleInPageTags = getStyleInPageTags;
8
12
  var getStyleTags = function (parsedHtml) {
9
13
  return Array.from(parsedHtml.window.document.getElementsByTagName('link')).filter(function (s) { return s.getAttribute('rel') === 'stylesheet'; });
10
14
  };
@@ -17,3 +21,7 @@ var getImgTags = function (parsedHtml) {
17
21
  return Array.from(parsedHtml.window.document.getElementsByTagName('img')).filter(function (s) { return s.getAttribute('src'); });
18
22
  };
19
23
  exports.getImgTags = getImgTags;
24
+ var getSourceTags = function (parsedHtml) {
25
+ return Array.from(parsedHtml.window.document.getElementsByTagName('source')).filter(function (s) { return s.getAttribute('src'); });
26
+ };
27
+ exports.getSourceTags = getSourceTags;
@@ -0,0 +1,23 @@
1
+ declare function init(): void;
2
+ declare function main(): void;
3
+ declare function update(dt: any): void;
4
+ declare function handleInput(dt: any): void;
5
+ declare function updateEntities(dt: any, gameTime: any): void;
6
+ declare function checkCollisions(): void;
7
+ declare function render(): void;
8
+ declare function renderEntity(entity: any): void;
9
+ declare var requestAnimFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
10
+ declare var canvas: HTMLCanvasElement;
11
+ declare var ctx: CanvasRenderingContext2D | null;
12
+ declare var updateables: any[];
13
+ declare var fireballs: any[];
14
+ declare var player: any;
15
+ declare var vX: number;
16
+ declare var vY: number;
17
+ declare var vWidth: number;
18
+ declare var vHeight: number;
19
+ declare var level: any;
20
+ declare var sounds: any;
21
+ declare var music: any;
22
+ declare var lastTime: any;
23
+ declare var gameTime: number;
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ // game.js from SASjs/Mario
3
+ // https://github.com/sasjs/mario/blob/main/src/js/game.js
4
+ var requestAnimFrame = (function () {
5
+ return (window.requestAnimationFrame ||
6
+ window.webkitRequestAnimationFrame ||
7
+ window.mozRequestAnimationFrame ||
8
+ window.oRequestAnimationFrame ||
9
+ window.msRequestAnimationFrame ||
10
+ function (callback) {
11
+ window.setTimeout(callback, 1000 / 60);
12
+ });
13
+ })();
14
+ //create the canvas
15
+ var canvas = document.createElement('canvas');
16
+ var ctx = canvas.getContext('2d');
17
+ var updateables = [];
18
+ var fireballs = [];
19
+ var player = new Mario.Player([0, 0]);
20
+ //we might have to get the size and calculate the scaling
21
+ //but this method should let us make it however big.
22
+ //Cool!
23
+ //TODO: Automatically scale the game to work and look good on widescreen.
24
+ //TODO: fiddling with scaled sprites looks BETTER, but not perfect. Hmm.
25
+ canvas.width = 762;
26
+ canvas.height = 720;
27
+ ctx.scale(3, 3);
28
+ document.body.appendChild(canvas);
29
+ //viewport
30
+ var vX = 0, vY = 0, vWidth = 256, vHeight = 240;
31
+ //load our images
32
+ resources.load([
33
+ 'sprites/player.png',
34
+ 'sprites/enemy.png',
35
+ 'sprites/tiles.png',
36
+ 'sprites/playerl.png',
37
+ 'sprites/items.png',
38
+ 'sprites/enemyr.png'
39
+ ]);
40
+ resources.onReady(init);
41
+ var level;
42
+ var sounds;
43
+ var music;
44
+ //initialize
45
+ var lastTime;
46
+ function init() {
47
+ music = {
48
+ overworld: new Audio('sounds/aboveground_bgm.ogg'),
49
+ underground: new Audio('sounds/underground_bgm.ogg'),
50
+ clear: new Audio('sounds/stage_clear.wav'),
51
+ death: new Audio('sounds/mariodie.wav')
52
+ };
53
+ sounds = {
54
+ smallJump: new Audio('sounds/jump-small.wav'),
55
+ bigJump: new Audio('sounds/jump-super.wav'),
56
+ breakBlock: new Audio('sounds/breakblock.wav'),
57
+ bump: new Audio('sounds/bump.wav'),
58
+ coin: new Audio('sounds/coin.wav'),
59
+ fireball: new Audio('sounds/fireball.wav'),
60
+ flagpole: new Audio('sounds/flagpole.wav'),
61
+ kick: new Audio('sounds/kick.wav'),
62
+ pipe: new Audio('sounds/pipe.wav'),
63
+ itemAppear: new Audio('sounds/itemAppear.wav'),
64
+ powerup: new Audio('sounds/powerup.wav'),
65
+ stomp: new Audio('sounds/stomp.wav')
66
+ };
67
+ Mario.oneone();
68
+ lastTime = Date.now();
69
+ main();
70
+ }
71
+ var gameTime = 0;
72
+ //set up the game loop
73
+ function main() {
74
+ var now = Date.now();
75
+ var dt = (now - lastTime) / 1000.0;
76
+ update(dt);
77
+ render();
78
+ lastTime = now;
79
+ requestAnimFrame(main);
80
+ }
81
+ function update(dt) {
82
+ gameTime += dt;
83
+ handleInput(dt);
84
+ updateEntities(dt, gameTime);
85
+ checkCollisions();
86
+ }
87
+ function handleInput(dt) {
88
+ if (player.piping || player.dying || player.noInput)
89
+ return; //don't accept input
90
+ if (input.isDown('RUN')) {
91
+ player.run();
92
+ }
93
+ else {
94
+ player.noRun();
95
+ }
96
+ if (input.isDown('JUMP')) {
97
+ player.jump();
98
+ }
99
+ else {
100
+ //we need this to handle the timing for how long you hold it
101
+ player.noJump();
102
+ }
103
+ if (input.isDown('DOWN')) {
104
+ player.crouch();
105
+ }
106
+ else {
107
+ player.noCrouch();
108
+ }
109
+ if (input.isDown('LEFT')) {
110
+ // 'd' or left arrow
111
+ player.moveLeft();
112
+ }
113
+ else if (input.isDown('RIGHT')) {
114
+ // 'k' or right arrow
115
+ player.moveRight();
116
+ }
117
+ else {
118
+ player.noWalk();
119
+ }
120
+ }
121
+ //update all the moving stuff
122
+ function updateEntities(dt, gameTime) {
123
+ player.update(dt, vX);
124
+ updateables.forEach(function (ent) {
125
+ ent.update(dt, gameTime);
126
+ });
127
+ //This should stop the jump when he switches sides on the flag.
128
+ if (player.exiting) {
129
+ if (player.pos[0] > vX + 96)
130
+ vX = player.pos[0] - 96;
131
+ }
132
+ else if (level.scrolling && player.pos[0] > vX + 80) {
133
+ vX = player.pos[0] - 80;
134
+ }
135
+ if (player.powering.length !== 0 || player.dying) {
136
+ return;
137
+ }
138
+ level.items.forEach(function (ent) {
139
+ ent.update(dt);
140
+ });
141
+ level.enemies.forEach(function (ent) {
142
+ ent.update(dt, vX);
143
+ });
144
+ fireballs.forEach(function (fireball) {
145
+ fireball.update(dt);
146
+ });
147
+ level.pipes.forEach(function (pipe) {
148
+ pipe.update(dt);
149
+ });
150
+ }
151
+ //scan for collisions
152
+ function checkCollisions() {
153
+ if (player.powering.length !== 0 || player.dying) {
154
+ return;
155
+ }
156
+ player.checkCollisions();
157
+ //Apparently for each will just skip indices where things were deleted.
158
+ level.items.forEach(function (item) {
159
+ item.checkCollisions();
160
+ });
161
+ level.enemies.forEach(function (ent) {
162
+ ent.checkCollisions();
163
+ });
164
+ fireballs.forEach(function (fireball) {
165
+ fireball.checkCollisions();
166
+ });
167
+ level.pipes.forEach(function (pipe) {
168
+ pipe.checkCollisions();
169
+ });
170
+ }
171
+ //draw the game!
172
+ function render() {
173
+ updateables = [];
174
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
175
+ ctx.fillStyle = level.background;
176
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
177
+ //scenery gets drawn first to get layering right.
178
+ for (var i = 0; i < 15; i++) {
179
+ for (var j = Math.floor(vX / 16) - 1; j < Math.floor(vX / 16) + 20; j++) {
180
+ if (level.scenery[i][j]) {
181
+ renderEntity(level.scenery[i][j]);
182
+ }
183
+ }
184
+ }
185
+ //then items
186
+ level.items.forEach(function (item) {
187
+ renderEntity(item);
188
+ });
189
+ level.enemies.forEach(function (enemy) {
190
+ renderEntity(enemy);
191
+ });
192
+ fireballs.forEach(function (fireball) {
193
+ renderEntity(fireball);
194
+ });
195
+ //then we draw every static object.
196
+ for (var i = 0; i < 15; i++) {
197
+ for (var j = Math.floor(vX / 16) - 1; j < Math.floor(vX / 16) + 20; j++) {
198
+ if (level.statics[i][j]) {
199
+ renderEntity(level.statics[i][j]);
200
+ }
201
+ if (level.blocks[i][j]) {
202
+ renderEntity(level.blocks[i][j]);
203
+ updateables.push(level.blocks[i][j]);
204
+ }
205
+ }
206
+ }
207
+ //then the player
208
+ if (player.invincibility % 2 === 0) {
209
+ renderEntity(player);
210
+ }
211
+ //Mario goes INTO pipes, so naturally they go after.
212
+ level.pipes.forEach(function (pipe) {
213
+ renderEntity(pipe);
214
+ });
215
+ }
216
+ function renderEntity(entity) {
217
+ entity.render(ctx, vX, vY);
218
+ }
@@ -26,7 +26,7 @@ describe('updateLinkTag', function () {
26
26
  source: 'image.jpeg',
27
27
  target: sasProgramPath
28
28
  });
29
- (0, updateLinkTag_1.updateLinkTag)(imgTag, assetPathMap, 'image');
29
+ (0, updateLinkTag_1.updateLinkTag)(imgTag, assetPathMap, 'src');
30
30
  expect(imgTag.getAttribute('src')).toEqual(sasProgramPath);
31
31
  });
32
32
  });