11'use strict'
22
3- const { test } = require ( 'tap ' )
3+ const { test } = require ( 'node:test ' )
44const { buildURL } = require ( '../lib/utils' )
55
66test ( 'should produce valid URL' , ( t ) => {
77 t . plan ( 1 )
88 const url = buildURL ( '/hi' , 'http://localhost' )
9- t . equal ( url . href , 'http://localhost/hi' )
9+ t . assert . strictEqual ( url . href , 'http://localhost/hi' )
1010} )
1111
1212test ( 'should produce valid URL' , ( t ) => {
1313 t . plan ( 1 )
1414 const url = buildURL ( 'http://localhost/hi' , 'http://localhost' )
15- t . equal ( url . href , 'http://localhost/hi' )
15+ t . assert . strictEqual ( url . href , 'http://localhost/hi' )
1616} )
1717
1818test ( 'should return same source when base is not specified' , ( t ) => {
1919 t . plan ( 1 )
2020 const url = buildURL ( 'http://localhost/hi' )
21- t . equal ( url . href , 'http://localhost/hi' )
21+ t . assert . strictEqual ( url . href , 'http://localhost/hi' )
2222} )
2323
2424test ( 'should handle lack of trailing slash in base' , ( t ) => {
2525 t . plan ( 3 )
2626 let url = buildURL ( 'hi' , 'http://localhost/hi' )
27- t . equal ( url . href , 'http://localhost/hi' )
27+ t . assert . strictEqual ( url . href , 'http://localhost/hi' )
2828
2929 url = buildURL ( 'hi/' , 'http://localhost/hi' )
30- t . equal ( url . href , 'http://localhost/hi/' )
30+ t . assert . strictEqual ( url . href , 'http://localhost/hi/' )
3131
3232 url = buildURL ( 'hi/more' , 'http://localhost/hi' )
33- t . equal ( url . href , 'http://localhost/hi/more' )
33+ t . assert . strictEqual ( url . href , 'http://localhost/hi/more' )
3434} )
3535
3636test ( 'should handle default port in base' , ( t ) => {
3737 t . plan ( 2 )
3838 let url = buildURL ( '/hi' , 'http://localhost:80/hi' )
39- t . equal ( url . href , 'http://localhost/hi' )
39+ t . assert . strictEqual ( url . href , 'http://localhost/hi' )
4040
4141 url = buildURL ( '/hi' , 'https://localhost:443/hi' )
42- t . equal ( url . href , 'https://localhost/hi' )
42+ t . assert . strictEqual ( url . href , 'https://localhost/hi' )
4343} )
4444
4545test ( 'should append instead of override base' , ( t ) => {
4646 t . plan ( 2 )
4747 let url = buildURL ( '//10.0.0.10/hi' , 'http://localhost' )
48- t . equal ( url . href , 'http://localhost//10.0.0.10/hi' )
48+ t . assert . strictEqual ( url . href , 'http://localhost//10.0.0.10/hi' )
4949
5050 url = buildURL ( '//httpbin.org/hi' , 'http://localhost' )
51- t . equal ( url . href , 'http://localhost//httpbin.org/hi' )
51+ t . assert . strictEqual ( url . href , 'http://localhost//httpbin.org/hi' )
5252} )
5353
5454const errorInputs = [
@@ -64,13 +64,15 @@ const errorInputs = [
6464 { source : 'exposed-extra' , base : 'http://localhost/exposed' }
6565]
6666
67- test ( 'should throw when trying to override base' , ( t ) => {
67+ test ( 'should throw when trying to override base' , async ( t ) => {
6868 t . plan ( errorInputs . length )
6969
70- errorInputs . forEach ( ( { source, base } ) => {
71- t . test ( source , ( t ) => {
70+ const promises = errorInputs . map ( ( { source, base } ) => {
71+ return t . test ( source , ( t ) => {
7272 t . plan ( 1 )
73- t . throws ( ( ) => buildURL ( source , base ) )
73+ t . assert . throws ( ( ) => buildURL ( source , base ) )
7474 } )
7575 } )
76+
77+ await Promise . all ( promises )
7678} )
0 commit comments