11'use strict'
22
3- const { tspl } = require ( '@matteo.collina/tspl' )
43const { test, describe } = require ( 'node:test' )
54const { MockCallHistoryLog } = require ( '../lib/mock/mock-call-history' )
65const { InvalidArgumentError } = require ( '../lib/core/errors' )
76
87describe ( 'MockCallHistoryLog - constructor' , ( ) => {
98 function assertConsistent ( t , mockCallHistoryLog ) {
10- t . strictEqual ( mockCallHistoryLog . body , null )
11- t . strictEqual ( mockCallHistoryLog . headers , undefined )
12- t . deepStrictEqual ( mockCallHistoryLog . searchParams , { query : 'value' } )
13- t . strictEqual ( mockCallHistoryLog . method , 'PUT' )
14- t . strictEqual ( mockCallHistoryLog . origin , 'https://localhost:4000' )
15- t . strictEqual ( mockCallHistoryLog . path , '/endpoint' )
16- t . strictEqual ( mockCallHistoryLog . hash , '#here' )
17- t . strictEqual ( mockCallHistoryLog . protocol , 'https:' )
18- t . strictEqual ( mockCallHistoryLog . host , 'localhost:4000' )
19- t . strictEqual ( mockCallHistoryLog . port , '4000' )
9+ t . assert . strictEqual ( mockCallHistoryLog . body , null )
10+ t . assert . strictEqual ( mockCallHistoryLog . headers , undefined )
11+ t . assert . deepStrictEqual ( mockCallHistoryLog . searchParams , { query : 'value' } )
12+ t . assert . strictEqual ( mockCallHistoryLog . method , 'PUT' )
13+ t . assert . strictEqual ( mockCallHistoryLog . origin , 'https://localhost:4000' )
14+ t . assert . strictEqual ( mockCallHistoryLog . path , '/endpoint' )
15+ t . assert . strictEqual ( mockCallHistoryLog . hash , '#here' )
16+ t . assert . strictEqual ( mockCallHistoryLog . protocol , 'https:' )
17+ t . assert . strictEqual ( mockCallHistoryLog . host , 'localhost:4000' )
18+ t . assert . strictEqual ( mockCallHistoryLog . port , '4000' )
2019 }
2120
2221 test ( 'should populate class properties with query in path' , t => {
23- t = tspl ( t , { plan : 10 } )
22+ t . plan ( 10 )
2423
2524 const mockCallHistoryLog = new MockCallHistoryLog ( {
2625 body : null ,
@@ -34,7 +33,7 @@ describe('MockCallHistoryLog - constructor', () => {
3433 } )
3534
3635 test ( 'should populate class properties with query in argument' , t => {
37- t = tspl ( t , { plan : 10 } )
36+ t . plan ( 10 )
3837
3938 const mockCallHistoryLog = new MockCallHistoryLog ( {
4039 body : null ,
@@ -49,15 +48,15 @@ describe('MockCallHistoryLog - constructor', () => {
4948 } )
5049
5150 test ( 'should throw when url computing failed' , t => {
52- t = tspl ( t , { plan : 1 } )
51+ t . plan ( 1 )
5352
54- t . throws ( ( ) => new MockCallHistoryLog ( { } ) , new InvalidArgumentError ( 'An error occurred when computing MockCallHistoryLog.url' ) )
53+ t . assert . throws ( ( ) => new MockCallHistoryLog ( { } ) , new InvalidArgumentError ( 'An error occurred when computing MockCallHistoryLog.url' ) )
5554 } )
5655} )
5756
5857describe ( 'MockCallHistoryLog - toMap' , ( ) => {
5958 test ( 'should return a Map of eleven element' , t => {
60- t = tspl ( t , { plan : 1 } )
59+ t . plan ( 1 )
6160
6261 const mockCallHistoryLog = new MockCallHistoryLog ( {
6362 body : '"{}"' ,
@@ -67,13 +66,13 @@ describe('MockCallHistoryLog - toMap', () => {
6766 path : '/endpoint?query=value#here'
6867 } )
6968
70- t . strictEqual ( mockCallHistoryLog . toMap ( ) . size , 11 )
69+ t . assert . strictEqual ( mockCallHistoryLog . toMap ( ) . size , 11 )
7170 } )
7271} )
7372
7473describe ( 'MockCallHistoryLog - toString' , ( ) => {
7574 test ( 'should return a string with all property' , t => {
76- t = tspl ( t , { plan : 1 } )
75+ t . plan ( 1 )
7776
7877 const mockCallHistoryLog = new MockCallHistoryLog ( {
7978 body : '"{ "data": "hello" }"' ,
@@ -83,11 +82,11 @@ describe('MockCallHistoryLog - toString', () => {
8382 path : '/endpoint?query=value#here'
8483 } )
8584
86- t . strictEqual ( mockCallHistoryLog . toString ( ) , 'protocol->https:|host->localhost:4000|port->4000|origin->https://localhost:4000|path->/endpoint|hash->#here|searchParams->{"query":"value"}|fullUrl->https://localhost:4000/endpoint?query=value#here|method->PUT|body->"{ "data": "hello" }"|headers->{"content-type":"application/json"}' )
85+ t . assert . strictEqual ( mockCallHistoryLog . toString ( ) , 'protocol->https:|host->localhost:4000|port->4000|origin->https://localhost:4000|path->/endpoint|hash->#here|searchParams->{"query":"value"}|fullUrl->https://localhost:4000/endpoint?query=value#here|method->PUT|body->"{ "data": "hello" }"|headers->{"content-type":"application/json"}' )
8786 } )
8887
8988 test ( 'should return a string when headers is an Array of string Array' , t => {
90- t = tspl ( t , { plan : 1 } )
89+ t . plan ( 1 )
9190
9291 const mockCallHistoryLog = new MockCallHistoryLog ( {
9392 body : '"{ "data": "hello" }"' ,
@@ -97,6 +96,6 @@ describe('MockCallHistoryLog - toString', () => {
9796 path : '/endpoint?query=value#here'
9897 } )
9998
100- t . strictEqual ( mockCallHistoryLog . toString ( ) , 'protocol->https:|host->localhost:4000|port->4000|origin->https://localhost:4000|path->/endpoint|hash->#here|searchParams->{"query":"value"}|fullUrl->https://localhost:4000/endpoint?query=value#here|method->PUT|body->"{ "data": "hello" }"|headers->["content-type",["application/json","application/xml"]]' )
99+ t . assert . strictEqual ( mockCallHistoryLog . toString ( ) , 'protocol->https:|host->localhost:4000|port->4000|origin->https://localhost:4000|path->/endpoint|hash->#here|searchParams->{"query":"value"}|fullUrl->https://localhost:4000/endpoint?query=value#here|method->PUT|body->"{ "data": "hello" }"|headers->["content-type",["application/json","application/xml"]]' )
101100 } )
102101} )
0 commit comments