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
This commit is contained in:
parent
0ec4ad288d
commit
9b6a37ead7
1 changed files with 6 additions and 1 deletions
|
@ -289,12 +289,17 @@ describe('session module', () => {
|
||||||
res.end(mockPDF)
|
res.end(mockPDF)
|
||||||
downloadServer.close()
|
downloadServer.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isPathEqual = (path1, path2) => {
|
||||||
|
return path.relative(path1, path2) === ''
|
||||||
|
}
|
||||||
const assertDownload = (event, state, url, mimeType,
|
const assertDownload = (event, state, url, mimeType,
|
||||||
receivedBytes, totalBytes, disposition,
|
receivedBytes, totalBytes, disposition,
|
||||||
filename, port, savePath, isCustom) => {
|
filename, port, savePath, isCustom) => {
|
||||||
assert.equal(state, 'completed')
|
assert.equal(state, 'completed')
|
||||||
assert.equal(filename, 'mock.pdf')
|
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) {
|
if (isCustom) {
|
||||||
assert.equal(url, `${protocolName}://item`)
|
assert.equal(url, `${protocolName}://item`)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue