diff --git a/karma-base.js b/karma-base.js index be0daab605..a310ba409f 100644 --- a/karma-base.js +++ b/karma-base.js @@ -341,6 +341,11 @@ module.exports = function (config) { frameworks: [ 'jasmine', 'sinon' ], + client: { + jasmine: { + random: false + } + }, webpack: { cache: true, devtool: 'inline-source-map', diff --git a/package-lock.json b/package-lock.json index db4659f533..4680cd9572 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2948,12 +2948,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "5.1.1", "yallist": "3.0.2" @@ -2972,6 +2974,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3065,6 +3068,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1.0.2" } @@ -3186,6 +3190,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "1.1.0", "is-fullwidth-code-point": "1.0.0", @@ -4252,9 +4257,9 @@ } }, "jasmine-core": { - "version": "2.99.1", - "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", - "integrity": "sha1-5kAN8ea1bhMLYcS80JPap/boyhU=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.1.0.tgz", + "integrity": "sha1-pHheE11d9lAk38kiSVPfWFvSdmw=", "dev": true }, "jquery": { @@ -4550,11 +4555,11 @@ "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", "dev": true, "requires": { - "esprima": "2.7.3", - "estraverse": "1.9.3", - "esutils": "2.0.2", - "optionator": "0.8.2", - "source-map": "0.2.0" + "esprima": "^2.7.1", + "estraverse": "^1.9.1", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.2.0" }, "dependencies": { "source-map": { @@ -4564,7 +4569,7 @@ "dev": true, "optional": true, "requires": { - "amdefine": "1.0.1" + "amdefine": ">=0.0.4" } } } @@ -4581,11 +4586,11 @@ "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", "dev": true, "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "istanbul": { @@ -4594,20 +4599,20 @@ "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", "dev": true, "requires": { - "abbrev": "1.0.9", - "async": "1.5.2", - "escodegen": "1.8.1", - "esprima": "2.7.3", - "glob": "5.0.15", - "handlebars": "4.0.11", - "js-yaml": "3.11.0", - "mkdirp": "0.5.1", - "nopt": "3.0.6", - "once": "1.4.0", - "resolve": "1.1.7", - "supports-color": "3.2.3", - "which": "1.3.0", - "wordwrap": "1.0.0" + "abbrev": "1.0.x", + "async": "1.x", + "escodegen": "1.8.x", + "esprima": "2.7.x", + "glob": "^5.0.15", + "handlebars": "^4.0.1", + "js-yaml": "3.x", + "mkdirp": "0.5.x", + "nopt": "3.x", + "once": "1.x", + "resolve": "1.1.x", + "supports-color": "^3.1.0", + "which": "^1.1.1", + "wordwrap": "^1.0.0" } }, "lodash": { @@ -4622,7 +4627,7 @@ "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", "dev": true, "requires": { - "has-flag": "1.0.0" + "has-flag": "^1.0.0" } } } @@ -4640,13 +4645,10 @@ "dev": true }, "karma-jasmine-html-reporter": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/karma-jasmine-html-reporter/-/karma-jasmine-html-reporter-0.2.2.tgz", - "integrity": "sha1-SKjl7xiAdhfuK14zwRlMNbQ5Ukw=", - "dev": true, - "requires": { - "karma-jasmine": "^1.0.2" - } + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/karma-jasmine-html-reporter/-/karma-jasmine-html-reporter-1.1.0.tgz", + "integrity": "sha512-uhNED+4B1axgptXkM8cCa3kztpQqsPrOxhfbjr4FdunNexnU6+cF2bfiIeGfsFMhphVyOMKy/S9LFaOFj8VXRA==", + "dev": true }, "karma-phantomjs-launcher": { "version": "1.0.4", diff --git a/package.json b/package.json index 7fa3c0f1d5..6c302a1ae9 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "istanbul-combine": "^0.3.0", "istanbul-instrumenter-loader": "^3.0.1", "jaguarjs-jsdoc": "^1.0.2", - "jasmine-core": "^2.4.1", + "jasmine-core": "^3.1.0", "jquery": "^3.3", "js-yaml": "^3.10.0", "jsdoc": "^3.5", @@ -59,7 +59,7 @@ "karma-coverage": "^1.0.0", "karma-firefox-launcher": "^1.1.0", "karma-jasmine": "^1.0.2", - "karma-jasmine-html-reporter": "^0.2.0", + "karma-jasmine-html-reporter": "^1.1.0", "karma-phantomjs-launcher": "^1.0.0", "karma-sinon": "^1.0.4", "karma-sourcemap-loader": "^0.3.7", diff --git a/src/gl/lineFeature.js b/src/gl/lineFeature.js index 04e1aa5fda..6b4c5bf98f 100644 --- a/src/gl/lineFeature.js +++ b/src/gl/lineFeature.js @@ -398,6 +398,7 @@ var gl_lineFeature = function (arg) { miterLimit = m_this.style.get('miterLimit')(data), antialiasing = m_this.style.get('antialiasing')(data) || 0, order = m_this.featureVertices(), + orderLen = order.length, posBuf, prevBuf, nextBuf, farBuf, flagsBuf, indicesBuf, fixedFlags = (flagsDebug[m_this.style.get('debug')(data) ? 'debug' : 'normal'] || 0), strokeWidthBuf, strokeColorBuf, strokeOpacityBuf, @@ -458,7 +459,7 @@ var gl_lineFeature = function (arg) { position = transform.transformCoordinates( m_this.gcs(), m_this.layer().map().gcs(), position, 3); - len = numSegments * order.length; + len = numSegments * orderLen; posBuf = util.getGeomBuffer(geom, 'pos', len * 3); prevBuf = util.getGeomBuffer(geom, 'prev', len * 3); nextBuf = util.getGeomBuffer(geom, 'next', len * 3); @@ -482,7 +483,7 @@ var gl_lineFeature = function (arg) { numSegments = m_geometry.numSegments; closed = m_geometry.closed; lineItemList = m_geometry.lineItemList; - len = numSegments * order.length; + len = numSegments * orderLen; updateFlags = ( (lineCapVal !== m_geometry.lineCapVal || lineCapVal === undefined) || (lineJoinVal !== m_geometry.lineJoinVal || lineJoinVal === undefined) || @@ -548,7 +549,7 @@ var gl_lineFeature = function (arg) { if (j) { /* zero out the z position. This can be changed if we handle it in * the shader. */ - for (k = 0; k < order.length; k += 1, dest += 1, dest3 += 3) { + for (k = 0; k < orderLen; k += 1, dest += 1, dest3 += 3) { v = vert[order[k][0]]; v2 = vert[1 - order[k][0]]; if (!onlyStyle) { diff --git a/tests/tutorials.js b/tests/tutorials.js index 506f4ea3c0..e32a25ee75 100644 --- a/tests/tutorials.js +++ b/tests/tutorials.js @@ -29,6 +29,8 @@ describe('tutorials', function () { var base$, tests; base$ = $('iframe#map')[0].contentWindow.jQuery; + /* Never complain if there are no explicit expect statements */ + expect().nothing(); /* If a codeblock test requires html video and the current browser * doesn't support video, skip the test. */ if (!$('iframe#map')[0].contentWindow.HTMLVideoElement && base$('.codeblock[htmlvideo]').length) { @@ -51,6 +53,8 @@ describe('tutorials', function () { var targetWindow = target[0].contentWindow, tut$ = targetWindow.$, deferreds = []; + /* Description of the current tutorial and test. */ + var desc = $('iframe#map')[0].contentWindow.document.title + ' - ' + test.data('description'); /* Evaluate and wait for each idle function and promises. */ test.data('idlefuncs').forEach(function (idleFunc) { var defer = tut$.Deferred(); @@ -66,21 +70,26 @@ describe('tutorials', function () { /* When all idle functions have resolved, evaluate each test in * the test list. */ tut$.when.apply(tut$, deferreds).fail(function () { - throw new Error('Idle functions were rejected'); + fail(desc + ' -> idle functions were rejected'); }).then(function () { var subtestDeferreds = []; test.data('tests').forEach(function (testExp) { /* The test expression can return a value or a promise. We * use jQuery's when to generically get the results in a * resolution function. A rejection is a failure. */ - var testResult = targetWindow.eval(testExp); + try { + var testResult = targetWindow.eval(testExp); + } catch (err) { + fail(desc + ' -> raised an error: ' + err); + return; + } var subtestDefer = tut$.when(testResult).done(function (result) { /* If the result isn't truthy, make sure our expect has a * description telling which test block and specific test * failed. */ - expect(result).toBeTruthy(test.data('description') + ' -> ' + testExp); + expect(result).toBeTruthy(desc + ' -> ' + testExp); }).fail(function () { - expect(false).toBeTruthy(test.data('description') + ' promise failed -> ' + testExp); + fail(desc + ' promise failed -> ' + testExp); }); subtestDeferreds.push(subtestDefer); }); @@ -109,7 +118,7 @@ describe('tutorials', function () { }); /* Call the first step in the chained tests */ done(); - }, 15000); + }, 150000); }); }); }); diff --git a/tutorials/common/tutorials.js b/tutorials/common/tutorials.js index 5ee61256d4..00b3aa355f 100644 --- a/tutorials/common/tutorials.js +++ b/tutorials/common/tutorials.js @@ -139,7 +139,6 @@ function process_block(selector) { * test's parent window to make debugging easier. */ if (window.parent && window.parent !== window) { js = 'window.console = window.parent.parent.console;\n' + - 'console.log("Testing " + window.parent.document.title);\n' + js; } html = html.substr(0, pos).replace(/\s+$/, '') + '\n\n' + html.substr(pos); diff --git a/tutorials/contour/index.pug b/tutorials/contour/index.pug index 0ca3984c32..1af1757180 100644 --- a/tutorials/contour/index.pug +++ b/tutorials/contour/index.pug @@ -4,7 +4,7 @@ block mainTutorial :markdown-it # Tutorial - Contour Map First, let's create our map and add a base map and a feature layer. - + +codeblock('javascript', 1). var map = geo.map({ node: '#map', @@ -15,8 +15,8 @@ block mainTutorial var layer = map.createLayer('feature'); :markdown-it - Then load some data. - The data is grid data describing geospatial point elevation, a record of z value -9999 means there is no land data. + Then load some data. + The data is grid data describing geospatial point elevation, a record of z value -9999 means there is no land data. Since the data is relatively big, intead of adding inline data, we load asynchronously, and use [promise chain](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises) to chain up the following steps. +codeblock('javascript', 2, 1). var promise = Promise.resolve($.ajax({ @@ -24,7 +24,7 @@ block mainTutorial })); :markdown-it - Once the data is loaded. We create the contour feature with default color range. `min: 0` means only showing data with elevation. + Once the data is loaded, we create the contour feature with default color range. `min: 0` means only showing data with elevation. +codeblock('javascript', 3, 2, true). var contour = null; diff --git a/tutorials/contour/thumb.jpg b/tutorials/contour/thumb.jpg index 20f735768e..5c301c6a30 100644 Binary files a/tutorials/contour/thumb.jpg and b/tutorials/contour/thumb.jpg differ