1- import { describe , test } from "@jest/globals" ;
2- import { expect } from "expect" ;
1+ import { describe , expect , test } from "vitest" ;
32
43import { endsWith , isEmpty , isMatch , parseVersion , prune , startsWith , stringify , toBoolean } from "#/Utils.js" ;
54
@@ -94,13 +93,9 @@ describe("Utils", () => {
9493 Object . entries ( typedArrayValues ) . forEach ( ( [ key , value ] ) => {
9594 test ( `for ${ key } ` , ( ) => {
9695 const actual = prune ( value , 1 ) ;
97-
98- if ( Array . isArray ( actual ) ) {
99- expect ( actual . length ) . toBe ( 1 ) ;
100- expect ( actual ) . toContain ( 1 ) ;
101- } else {
102- throw new Error ( "actual is not an array" ) ;
103- }
96+ expect ( Array . isArray ( actual ) ) . toBe ( true ) ;
97+ expect ( actual ) . toHaveLength ( 1 ) ;
98+ expect ( actual ) . toContain ( 1 ) ;
10499 } ) ;
105100 } ) ;
106101
@@ -112,13 +107,9 @@ describe("Utils", () => {
112107 Object . entries ( bigIntTypedArrayValues ) . forEach ( ( [ key , value ] ) => {
113108 test ( `for ${ key } ` , ( ) => {
114109 const actual = prune ( value , 1 ) ;
115-
116- if ( Array . isArray ( actual ) ) {
117- expect ( actual . length ) . toBe ( 1 ) ;
118- expect ( actual ) . toContain ( "1n" ) ;
119- } else {
120- throw new Error ( "actual is not an array" ) ;
121- }
110+ expect ( Array . isArray ( actual ) ) . toBe ( true ) ;
111+ expect ( actual ) . toHaveLength ( 1 ) ;
112+ expect ( actual ) . toContain ( "1n" ) ;
122113 } ) ;
123114 } ) ;
124115
@@ -166,15 +157,10 @@ describe("Utils", () => {
166157 } ) ;
167158
168159 test ( "for Error" , ( ) => {
169- try {
170- throw new Error ( "error" ) ;
171- } catch ( error ) {
172- if ( error instanceof Error ) {
173- const expected = { message : error . message , stack : error . stack } ;
174- const actual = prune ( error , 1 ) ;
175- expect ( actual ) . toStrictEqual ( expected ) ;
176- }
177- }
160+ const error = new Error ( "error" ) ;
161+ const expected = { message : error . message , stack : error . stack } ;
162+ const actual = prune ( error , 1 ) ;
163+ expect ( actual ) . toStrictEqual ( expected ) ;
178164 } ) ;
179165
180166 test ( "for Map" , ( ) => {
@@ -450,15 +436,10 @@ describe("Utils", () => {
450436 } ) ;
451437
452438 test ( "for Error" , ( ) => {
453- try {
454- throw new Error ( "error" ) ;
455- } catch ( error ) {
456- if ( error instanceof Error ) {
457- const expected = JSON . stringify ( { stack : error . stack , message : error . message } ) ;
458- const actual = stringify ( error , [ ] , 1 ) ;
459- expect ( actual ) . toStrictEqual ( expected ) ;
460- }
461- }
439+ const error = new Error ( "error" ) ;
440+ const expected = JSON . stringify ( { stack : error . stack , message : error . message } ) ;
441+ const actual = stringify ( error , [ ] , 1 ) ;
442+ expect ( actual ) . toStrictEqual ( expected ) ;
462443 } ) ;
463444
464445 test ( "for Map" , ( ) => {
@@ -619,11 +600,11 @@ describe("Utils", () => {
619600 } ) ;
620601
621602 test ( "*password*" , ( ) => {
622- JSON . stringify ( expect ( stringify ( user , [ "*password*" ] ) ) . toBe ( JSON . stringify ( { id : 1 , name : "Blake" , customValue : "Password" , value : { } } ) ) ) ;
603+ expect ( stringify ( user , [ "*password*" ] ) ) . toBe ( JSON . stringify ( { id : 1 , name : "Blake" , customValue : "Password" , value : { } } ) ) ;
623604 } ) ;
624605
625606 test ( "*Password*" , ( ) => {
626- JSON . stringify ( expect ( stringify ( user , [ "*Password*" ] ) ) . toBe ( JSON . stringify ( { id : 1 , name : "Blake" , customValue : "Password" , value : { } } ) ) ) ;
607+ expect ( stringify ( user , [ "*Password*" ] ) ) . toBe ( JSON . stringify ( { id : 1 , name : "Blake" , customValue : "Password" , value : { } } ) ) ;
627608 } ) ;
628609
629610 test ( "*Address" , ( ) => {
0 commit comments