Skip to content

Commit

Permalink
refactor: use node test runner utitities
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-michelet committed Oct 19, 2024
1 parent b2e502c commit bfd7380
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/routes/api/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
}

const file = await request.file()

if (!file) {
return reply.notFound('File not found')
}
Expand Down
13 changes: 7 additions & 6 deletions test/plugins/scrypt.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { test } from 'tap'
import { test } from 'node:test'
import Fastify from 'fastify'
import scryptPlugin from '../../src/plugins/custom/scrypt.js'
import assert from 'node:assert'

test('scrypt works standalone', async t => {
const app = Fastify()

t.teardown(() => app.close())
t.after(() => app.close())

app.register(scryptPlugin)

await app.ready()

const password = 'test_password'
const hash = await app.hash(password)
t.type(hash, 'string')
assert.ok(typeof hash === 'string')

const isValid = await app.compare(password, hash)
t.ok(isValid, 'compare should return true for correct password')
assert.ok(isValid, 'compare should return true for correct password')

const isInvalid = await app.compare('wrong_password', hash)
t.notOk(isInvalid, 'compare should return false for incorrect password')
assert.ok(!isInvalid, 'compare should return false for incorrect password')

await t.rejects(
await assert.rejects(
() => app.compare(password, 'malformed_hash'),
'compare should throw an error for malformed hash'
)
Expand Down
2 changes: 2 additions & 0 deletions uploads/tasks/13_one_line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions uploads/tasks/13_one_line_csv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bfd7380

Please sign in to comment.