Skip to content

Commit

Permalink
Use describe
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Jan 3, 2024
1 parent 7ca9944 commit 7123032
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions test/node-test/agent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { test, after } = require('node:test')
const { describe, test, after } = require('node:test')
const assert = require('node:assert/strict')
const http = require('http')
const { PassThrough } = require('stream')
Expand All @@ -18,24 +18,20 @@ const {
const importFresh = require('import-fresh')
const { tspl } = require('@matteo.collina/tspl')

test('setGlobalDispatcher', async t => {
const t1 = t.test('fails if agent does not implement `get` method', t => {
describe('setGlobalDispatcher', () => {
after(() => {
// reset globalAgent to a fresh Agent instance for later tests
setGlobalDispatcher(new Agent())
})
test('fails if agent does not implement `get` method', t => {
const p = tspl(t, { plan: 1 })
p.throws(() => setGlobalDispatcher({ dispatch: 'not a function' }), errors.InvalidArgumentError)
})

const t2 = t.test('sets global agent', async t => {
test('sets global agent', async t => {
const p = tspl(t, { plan: 2 })
p.doesNotThrow(() => setGlobalDispatcher(new Agent()))
p.doesNotThrow(() => setGlobalDispatcher({ dispatch: () => {} }))
})

await Promise.all([t1, t2])

t.after(() => {
// reset globalAgent to a fresh Agent instance for later tests
setGlobalDispatcher(new Agent())
})
})

test('Agent', t => {
Expand Down

0 comments on commit 7123032

Please sign in to comment.