11import { fileURLToPath , pathToFileURL } from 'node:url' ;
22import path from 'node:path' ;
3- import test from 'ava' ;
3+ import { test } from 'node:test' ;
4+ import assert from 'node:assert/strict' ;
45import { readPackage , readPackageSync , parsePackage } from '../index.js' ;
56
6- const dirname = path . dirname ( fileURLToPath ( test . meta . file ) ) ;
7+ const dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
78const rootCwd = path . join ( dirname , '..' ) ;
89
9- test ( 'async' , async t => {
10+ test ( 'async' , async ( ) => {
1011 const package_ = await readPackage ( ) ;
11- t . is ( package_ . name , 'unicorn' ) ;
12- t . truthy ( package_ . _id ) ;
12+ assert . strictEqual ( package_ . name , 'unicorn' ) ;
13+ assert . ok ( package_ . _id ) ;
1314} ) ;
1415
15- test ( 'async - cwd option' , async t => {
16+ test ( 'async - cwd option' , async ( ) => {
1617 const package_ = await readPackage ( { cwd : rootCwd } ) ;
17- t . is ( package_ . name , 'read-pkg' ) ;
18- t . deepEqual (
18+ assert . strictEqual ( package_ . name , 'read-pkg' ) ;
19+ assert . deepStrictEqual (
1920 await readPackage ( { cwd : pathToFileURL ( rootCwd ) } ) ,
2021 package_ ,
2122 ) ;
2223} ) ;
2324
24- test ( 'async - normalize option' , async t => {
25+ test ( 'async - normalize option' , async ( ) => {
2526 const package_ = await readPackage ( { normalize : false } ) ;
26- t . is ( package_ . name , 'unicorn ' ) ;
27+ assert . strictEqual ( package_ . name , 'unicorn ' ) ;
2728} ) ;
2829
29- test ( 'sync' , t => {
30+ test ( 'sync' , ( ) => {
3031 const package_ = readPackageSync ( ) ;
31- t . is ( package_ . name , 'unicorn' ) ;
32- t . truthy ( package_ . _id ) ;
32+ assert . strictEqual ( package_ . name , 'unicorn' ) ;
33+ assert . ok ( package_ . _id ) ;
3334} ) ;
3435
35- test ( 'sync - cwd option' , t => {
36+ test ( 'sync - cwd option' , ( ) => {
3637 const package_ = readPackageSync ( { cwd : rootCwd } ) ;
37- t . is ( package_ . name , 'read-pkg' ) ;
38- t . deepEqual (
38+ assert . strictEqual ( package_ . name , 'read-pkg' ) ;
39+ assert . deepStrictEqual (
3940 readPackageSync ( { cwd : pathToFileURL ( rootCwd ) } ) ,
4041 package_ ,
4142 ) ;
4243} ) ;
4344
44- test ( 'sync - normalize option' , t => {
45+ test ( 'sync - normalize option' , ( ) => {
4546 const package_ = readPackageSync ( { normalize : false } ) ;
46- t . is ( package_ . name , 'unicorn ' ) ;
47+ assert . strictEqual ( package_ . name , 'unicorn ' ) ;
4748} ) ;
4849
4950const pkgJson = {
@@ -52,53 +53,53 @@ const pkgJson = {
5253 type : 'module' ,
5354} ;
5455
55- test ( 'parsePackage - json input' , t => {
56+ test ( 'parsePackage - json input' , ( ) => {
5657 const package_ = parsePackage ( pkgJson ) ;
57- t . is ( package_ . name , 'unicorn' ) ;
58- t . deepEqual (
58+ assert . strictEqual ( package_ . name , 'unicorn' ) ;
59+ assert . deepStrictEqual (
5960 readPackageSync ( ) ,
6061 package_ ,
6162 ) ;
6263} ) ;
6364
64- test ( 'parsePackage - string input' , t => {
65+ test ( 'parsePackage - string input' , ( ) => {
6566 const package_ = parsePackage ( JSON . stringify ( pkgJson ) ) ;
66- t . is ( package_ . name , 'unicorn' ) ;
67- t . deepEqual (
67+ assert . strictEqual ( package_ . name , 'unicorn' ) ;
68+ assert . deepStrictEqual (
6869 readPackageSync ( ) ,
6970 package_ ,
7071 ) ;
7172} ) ;
7273
73- test ( 'parsePackage - normalize option' , t => {
74+ test ( 'parsePackage - normalize option' , ( ) => {
7475 const package_ = parsePackage ( pkgJson , { normalize : false } ) ;
75- t . is ( package_ . name , 'unicorn ' ) ;
76- t . deepEqual (
76+ assert . strictEqual ( package_ . name , 'unicorn ' ) ;
77+ assert . deepStrictEqual (
7778 readPackageSync ( { normalize : false } ) ,
7879 package_ ,
7980 ) ;
8081} ) ;
8182
82- test ( 'parsePackage - errors on invalid input' , t => {
83- t . throws (
83+ test ( 'parsePackage - errors on invalid input' , ( ) => {
84+ assert . throws (
8485 ( ) => parsePackage ( [ 'foo' , 'bar' ] ) ,
8586 { message : '`packageFile` should be either an `object` or a `string`.' } ,
8687 ) ;
8788
88- t . throws (
89+ assert . throws (
8990 ( ) => parsePackage ( null ) ,
9091 { message : '`packageFile` should be either an `object` or a `string`.' } ,
9192 ) ;
9293
93- t . throws (
94+ assert . throws (
9495 ( ) => parsePackage ( ( ) => ( { name : 'unicorn' } ) ) ,
9596 { message : '`packageFile` should be either an `object` or a `string`.' } ,
9697 ) ;
9798} ) ;
9899
99- test ( 'parsePackage - does not modify source object' , t => {
100+ test ( 'parsePackage - does not modify source object' , ( ) => {
100101 const pkgObject = { name : 'unicorn' , version : '1.0.0' } ;
101102 const package_ = parsePackage ( pkgObject ) ;
102103
103- t . not ( pkgObject , package_ ) ;
104+ assert . notStrictEqual ( pkgObject , package_ ) ;
104105} ) ;
0 commit comments