Skip to content

Commit

Permalink
test: keep the style of cases consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
KID-joker committed Nov 23, 2024
1 parent 261f843 commit 7ecd5a3
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import assert from 'node:assert/strict'
import { exec as execCallback } from 'node:child_process'
import { exec } from 'node:child_process'
import { test } from 'node:test'
import { promisify } from 'node:util'

const exec = promisify(execCallback)

test('current tests', async (t) => {
await t.test('check if no deprecation warning is shown', (_t, done) => {
Expand All @@ -13,12 +10,13 @@ test('current tests', async (t) => {
})
})

await t.test('check if deprecation warning is shown if deprecated package is installed', async (_t) => {
await exec('pnpm i request --force')
const { stderr } = await exec('node ./dist/cli.mjs current', { timeout: 160000 })
assert.ok(/request has been deprecated/.test(stderr), 'Expected "has been deprecated" to be mentioned in deprecation warning.')
// Cleanup: Undo the installation
await exec('pnpm remove request')
await t.test('check if deprecation warning is shown if deprecated package is installed', (_t, done) => {
exec('pnpm i request --force && node ./dist/cli.mjs current', { timeout: 160000 }, (_error, _stdout, stderr) => {
assert.ok(/request has been deprecated/.test(stderr), 'Expected "has been deprecated" to be mentioned in deprecation warning.')
// Cleanup: Undo the installation
exec('pnpm remove request')
done()
})
})
})

Expand All @@ -41,14 +39,14 @@ test('global tests', async (t) => {
})

test('package tests', async (t) => {
await t.test('check if deprecated package gets detected', (t, done) => {
await t.test('check if deprecated package gets detected', (_t, done) => {
exec('node ./dist/cli.mjs package request', (_error, _stdout, stderr) => {
assert.ok(/has been deprecated/.test(stderr), 'Expected "has been deprecated" to be mentioned in deprecation warning.')
done()
})
})

await t.test('check if not deprecated package does not get detected as deprecated', (t, done) => {
await t.test('check if not deprecated package does not get detected as deprecated', (_t, done) => {
exec('node ./dist/cli.mjs package eslint', (_error, _stdout, stderr) => {
assert.ok(!/has been deprecated/.test(stderr), 'Not expected "has been deprecated" to be mentioned in deprecation warning.')
done()
Expand Down

0 comments on commit 7ecd5a3

Please sign in to comment.