Skip to content

Commit

Permalink
Fixup tests
Browse files Browse the repository at this point in the history
Other than the one required change (at the end), I've also removed the
dependence of the current working directory being the repo's origin
(which makes it possible to run just this one test directly in IDEs)
  • Loading branch information
CommandMC committed Jan 11, 2024
1 parent 13c98ef commit 3655105
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jest.mock('@xhmikosr/decompress-targz', () => {
jest.mock('@felipecrs/decompress-tarxz', () => {
return jest.fn().mockImplementation(() => {})
})
const workDir = process.cwd()

describe('Utilities - Unzip', () => {
test('unzip file fails because of invalid archive path', async () => {
Expand All @@ -36,9 +35,7 @@ describe('Utilities - Unzip', () => {
unzipDir: __dirname,
onProgress: progress
})
).rejects.toStrictEqual(
`Archive path ${workDir}/src/backend/wine/manager/downloader/__tests__/utilities is not a file!`
)
).rejects.toStrictEqual(`Archive path ${__dirname} is not a file!`)
})

test('unzip file fails because of invalid install path', async () => {
Expand Down Expand Up @@ -67,7 +64,7 @@ describe('Utilities - Unzip', () => {
onProgress: progress
})
).resolves.toStrictEqual(
`Succesfully unzip ${workDir}/src/backend/wine/manager/downloader/__tests__/utilities/../test_data/test.tar.xz to ${workDir}/src/backend/wine/manager/downloader/__tests__/utilities/test_unzip.`
`Succesfully unzip ${__dirname}/../test_data/test.tar.xz to ${installDir}.`
)

if (existsSync(installDir)) {
Expand All @@ -90,7 +87,7 @@ describe('Utilities - Unzip', () => {
onProgress: progress
})
).resolves.toStrictEqual(
`Succesfully unzip ${workDir}/src/backend/wine/manager/downloader/__tests__/utilities/../test_data/test.tar.gz to ${workDir}/src/backend/wine/manager/downloader/__tests__/utilities/test_unzip.`
`Succesfully unzip ${__dirname}/../test_data/test.tar.gz to ${installDir}.`
)

if (existsSync(installDir)) {
Expand All @@ -113,7 +110,7 @@ describe('Utilities - Unzip', () => {
onProgress: progress
})
).resolves.toStrictEqual(
`Succesfully unzip ${workDir}/src/backend/wine/manager/downloader/__tests__/utilities/../test_data/test.tar.gz to ${workDir}/src/backend/wine/manager/downloader/__tests__/utilities/test_unzip.`
`Succesfully unzip ${__dirname}/../test_data/test.tar.gz to ${installDir}.`
)

await expect(
Expand All @@ -124,14 +121,14 @@ describe('Utilities - Unzip', () => {
onProgress: progress
})
).resolves.toStrictEqual(
`Succesfully unzip ${workDir}/src/backend/wine/manager/downloader/__tests__/utilities/../test_data/test.tar.gz to ${workDir}/src/backend/wine/manager/downloader/__tests__/utilities/test_unzip.`
`Succesfully unzip ${__dirname}/../test_data/test.tar.gz to ${installDir}.`
)

if (existsSync(installDir)) {
rmSync(installDir, { recursive: true })
}

expect(progress).toBeCalledWith('unzipping')
expect(progress).toBeCalledWith('idle')
expect(progress).toBeCalledWith({ status: 'unzipping' })
expect(progress).toBeCalledWith({ status: 'idle' })
})
})

0 comments on commit 3655105

Please sign in to comment.