From 0722da0b7afb72a6c78e3ed869c1b31fa39f87c1 Mon Sep 17 00:00:00 2001 From: lutovich Date: Fri, 15 Jun 2018 18:34:27 +0200 Subject: [PATCH 1/3] Fix query plan tests on neo4j 3.5 Operator type names have changed. This commit makes the assertions more generic. --- test/v1/session.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/v1/session.test.js b/test/v1/session.test.js index 3a88b086a..77c6913b0 100644 --- a/test/v1/session.test.js +++ b/test/v1/session.test.js @@ -291,10 +291,10 @@ describe('session', () => { const sum = result.summary; expect(sum.hasPlan()).toBe(true); expect(sum.hasProfile()).toBe(false); - expect(sum.plan.operatorType).toBe('ProduceResults'); + expect(sum.plan.operatorType).toBeDefined(); expect(isString(sum.plan.arguments.runtime)).toBeTruthy(); expect(sum.plan.identifiers[0]).toBe('n'); - expect(sum.plan.children[0].operatorType).toBe('CreateNode'); + expect(sum.plan.children[0].operatorType).toBeDefined(); done(); }); }); @@ -310,7 +310,7 @@ describe('session', () => { const sum = result.summary; expect(sum.hasPlan()).toBe(true); //When there's a profile, there's a plan expect(sum.hasProfile()).toBe(true); - expect(sum.profile.operatorType).toBe('ProduceResults'); + expect(sum.profile.operatorType).toBeDefined(); expect(isString(sum.profile.arguments.runtime)).toBeTruthy(); expect(sum.profile.identifiers[0]).toBe('n'); expect(sum.profile.children[0].operatorType).toBeDefined(); From b88af7f9295aaf1b7057a872e1a1856039ee7e36 Mon Sep 17 00:00:00 2001 From: lutovich Date: Mon, 18 Jun 2018 16:07:31 +0200 Subject: [PATCH 2/3] Upgrade karma to get rid of ES6 and ES7 polyfill Previous Karma version pulled in a polyfill that made it possible to use ES6 and ES7 features in tests. Such features might not be available during runtime and could result in errors. `String#padStart()` is an example of a feature that was used in the code and was added by the Karma polyfill. Tests worked just fine but driver code failed at runtime in older NodeJS versions. Note that Babel runtime that is used by the driver does not polyfill instance methods such as `String#padStart()`. --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ebd2f6234..f6daec078 100644 --- a/package.json +++ b/package.json @@ -52,13 +52,13 @@ "gulp-util": "^3.0.6", "gulp-watch": "^4.3.5", "jasmine-console-reporter": "^2.0.1", - "karma": "^1.7.1", + "karma": "^2.0.3", "karma-chrome-launcher": "^2.2.0", "karma-edge-launcher": "^0.4.2", - "karma-firefox-launcher": "^1.0.1", + "karma-firefox-launcher": "^1.1.0", "karma-ie-launcher": "^1.0.0", - "karma-jasmine": "^1.1.0", - "karma-spec-reporter": "^0.0.31", + "karma-jasmine": "^1.1.2", + "karma-spec-reporter": "^0.0.32", "lodash": "^4.17.4", "lolex": "^1.5.2", "minimist": "^1.2.0", From 33470805d88b3cb3e1a06aaecd9a4144e811d0c4 Mon Sep 17 00:00:00 2001 From: lutovich Date: Mon, 18 Jun 2018 16:37:20 +0200 Subject: [PATCH 3/3] Do not use `String#padStart()` It might not be available on older NodeJS and browsers. It can't be added by the Babel runtime because it is an instance function. Only Babel polyfill can add such functions and we can't use plyfill because it changes the global scope. --- src/v1/internal/temporal-util.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/v1/internal/temporal-util.js b/src/v1/internal/temporal-util.js index ca6a63bfa..903b0eb80 100644 --- a/src/v1/internal/temporal-util.js +++ b/src/v1/internal/temporal-util.js @@ -383,7 +383,13 @@ function formatNumber(num, stringLength = undefined) { if (isNegative) { num = num.negate(); } - const numString = num.toString(); - const paddedNumString = stringLength ? numString.padStart(stringLength, '0') : numString; - return isNegative ? '-' + paddedNumString : paddedNumString; + + let numString = num.toString(); + if (stringLength) { + // left pad the string with zeroes + while (numString.length < stringLength) { + numString = '0' + numString; + } + } + return isNegative ? '-' + numString : numString; }