From 40f0f049a22b77bdd51389aac0e74af37dda516d Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Fri, 14 Sep 2018 18:32:17 +1000 Subject: [PATCH] spec: fix final node and chromium specs after assert change --- spec/assert-helpers.js | 13 ++++++++++++- spec/chromium-spec.js | 9 +++++---- spec/node-spec.js | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/spec/assert-helpers.js b/spec/assert-helpers.js index fae8f45b6b72..a825f6d2a5c2 100644 --- a/spec/assert-helpers.js +++ b/spec/assert-helpers.js @@ -1,5 +1,16 @@ +function resolveSingleObjectGetters (object) { + if (object && typeof object === 'object') { + const newObject = {} + for (const key in object) { + newObject[key] = resolveGetters(object[key])[0] + } + return newObject + } + return object +} + function resolveGetters (...args) { - return args.map(o => JSON.parse(JSON.stringify(o))) + return args.map(resolveSingleObjectGetters) } module.exports = { diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index 78b23577dbc8..7a48a79f08cd 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -7,6 +7,7 @@ const url = require('url') const ChildProcess = require('child_process') const { ipcRenderer, remote } = require('electron') const { closeWindow } = require('./window-helpers') +const { resolveGetters } = require('./assert-helpers') const { app, BrowserWindow, ipcMain, protocol, session, webContents } = remote const isCI = remote.getGlobal('isCi') const features = process.atomBinding('features') @@ -457,8 +458,8 @@ describe('chromium feature', () => { w.loadFile(path.join(fixtures, 'pages', 'window-open.html')) w.webContents.once('new-window', (event, url, frameName, disposition, options) => { assert.strictEqual(options.show, false) - assert.deepStrictEqual(options.foo, { - bar: null, + assert.deepStrictEqual(...resolveGetters(options.foo, { + bar: undefined, baz: { hello: { world: true @@ -469,7 +470,7 @@ describe('chromium feature', () => { world: true } } - }) + })) done() }) }) @@ -614,7 +615,7 @@ describe('chromium feature', () => { it('does nothing when origin of current window does not match opener', (done) => { listener = (event) => { - assert.strictEqual(event.data, undefined) + assert.strictEqual(event.data, null) done() } window.addEventListener('message', listener) diff --git a/spec/node-spec.js b/spec/node-spec.js index 62e778bffb16..c3fd2188ef35 100644 --- a/spec/node-spec.js +++ b/spec/node-spec.js @@ -334,7 +334,7 @@ describe('node feature', () => { let iv = Buffer.from('0'.repeat(32), 'hex') let input = Buffer.from(data, 'base64') let decipher = crypto.createDecipheriv('aes-128-cbc', Buffer.from(key, 'base64'), iv) - let result = Buffer.concat([decipher.update(input), decipher.final()]) + let result = Buffer.concat([decipher.update(input), decipher.final()]).toString('utf8') assert.strictEqual(cipherText, result) } })