From 9b6a37ead70ed4deef45851a6b4d926c74c1a3c2 Mon Sep 17 00:00:00 2001 From: Tomas Rycl Date: Tue, 10 Jul 2018 13:38:11 +0200 Subject: [PATCH] test: Better path compare than just strings (#13548) * Better path comparision than just strings * Linter fix * Resolving paths first to always obtain absolute path so path.relative() can work * Using assert.ok which better fits the test * No need to resolve parameters of path.resolve * Added assertion to type of returned path for download item --- spec/api-session-spec.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/api-session-spec.js b/spec/api-session-spec.js index 7ac14e1f1f88..b9093d1d6335 100644 --- a/spec/api-session-spec.js +++ b/spec/api-session-spec.js @@ -289,12 +289,17 @@ describe('session module', () => { res.end(mockPDF) downloadServer.close() }) + + const isPathEqual = (path1, path2) => { + return path.relative(path1, path2) === '' + } const assertDownload = (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename, port, savePath, isCustom) => { assert.equal(state, 'completed') assert.equal(filename, 'mock.pdf') - assert.equal(savePath, path.join(__dirname, 'fixtures', 'mock.pdf')) + assert.ok(path.isAbsolute(savePath)) + assert.ok(isPathEqual(savePath, path.join(__dirname, 'fixtures', 'mock.pdf'))) if (isCustom) { assert.equal(url, `${protocolName}://item`) } else {