1
1
'use strict'
2
2
3
- const { test } = require ( 'tap ' )
3
+ const { test } = require ( 'node:test ' )
4
4
const fastq = require ( 'fastq' )
5
5
const boot = require ( '..' )
6
6
const { Plugin } = require ( '../lib/plugin' )
7
7
8
8
test ( 'loadedSoFar resolves a Promise, if plugin.loaded is set to true' , async ( t ) => {
9
- t . plan ( 1 )
10
9
const app = boot ( { } )
11
10
12
11
const plugin = new Plugin ( fastq ( app , app . _loadPluginNextTick , 1 ) , function ( instance , opts , done ) {
@@ -15,28 +14,27 @@ test('loadedSoFar resolves a Promise, if plugin.loaded is set to true', async (t
15
14
16
15
plugin . loaded = true
17
16
18
- await t . resolves ( plugin . loadedSoFar ( ) )
17
+ await plugin . loadedSoFar ( )
19
18
} )
20
19
21
20
test ( 'loadedSoFar resolves a Promise, if plugin was loaded by avvio' , async ( t ) => {
22
- t . plan ( 2 )
21
+ t . plan ( 1 )
23
22
const app = boot ( { } )
24
23
25
24
const plugin = new Plugin ( fastq ( app , app . _loadPluginNextTick , 1 ) , function ( instance , opts , done ) {
26
25
done ( )
27
26
} , false , 0 )
28
27
29
28
app . _loadPlugin ( plugin , function ( err ) {
30
- t . equal ( err , undefined )
29
+ t . assert . ifError ( err )
31
30
} )
32
31
33
32
await app . ready ( )
34
33
35
- await t . resolves ( plugin . loadedSoFar ( ) )
34
+ await plugin . loadedSoFar ( )
36
35
} )
37
36
38
37
test ( 'loadedSoFar resolves a Promise, if .after() has no error' , async t => {
39
- t . plan ( 1 )
40
38
const app = boot ( )
41
39
42
40
app . after = function ( callback ) {
@@ -49,7 +47,7 @@ test('loadedSoFar resolves a Promise, if .after() has no error', async t => {
49
47
50
48
app . _loadPlugin ( plugin , function ( ) { } )
51
49
52
- await t . resolves ( plugin . loadedSoFar ( ) )
50
+ await plugin . loadedSoFar ( )
53
51
} )
54
52
55
53
test ( 'loadedSoFar rejects a Promise, if .after() has an error' , async t => {
@@ -66,12 +64,10 @@ test('loadedSoFar rejects a Promise, if .after() has an error', async t => {
66
64
67
65
app . _loadPlugin ( plugin , function ( ) { } )
68
66
69
- await t . rejects ( plugin . loadedSoFar ( ) , new Error ( 'ArbitraryError' ) )
67
+ await t . assert . rejects ( plugin . loadedSoFar ( ) , new Error ( 'ArbitraryError' ) )
70
68
} )
71
69
72
70
test ( 'loadedSoFar resolves a Promise, if Plugin is attached to avvio after it the Plugin was instantiated' , async t => {
73
- t . plan ( 1 )
74
-
75
71
const plugin = new Plugin ( fastq ( null , null , 1 ) , function ( instance , opts , done ) {
76
72
done ( )
77
73
} , false , 0 )
@@ -80,5 +76,5 @@ test('loadedSoFar resolves a Promise, if Plugin is attached to avvio after it th
80
76
81
77
plugin . server = boot ( )
82
78
plugin . emit ( 'start' )
83
- await t . resolves ( promise )
79
+ await promise
84
80
} )
0 commit comments