1
- import dotenv from "dotenv" ;
2
- dotenv . config ( ) ;
3
-
4
1
// Import Node.js Dependencies
5
2
import { fileURLToPath } from "url" ;
6
3
import path from "path" ;
7
4
import fs from "fs/promises" ;
5
+ import { test } from "node:test" ;
6
+ import assert from "node:assert" ;
8
7
9
8
// Import Third-party Dependencies
10
- import test from "tape" ;
11
9
import is from "@slimio/is" ;
12
10
13
11
// Import Internal Dependency
@@ -19,65 +17,51 @@ const kDownloadDir = path.join(__dirname, "downloads");
19
17
20
18
await fs . mkdir ( kDownloadDir ) ;
21
19
22
- test ( "gitlab.download should be an asyncFunction" , ( tape ) => {
23
- tape . true ( is . func ( gitlab . download ) ) ;
24
- tape . true ( is . asyncFunction ( gitlab . download ) ) ;
25
-
26
- tape . end ( ) ;
20
+ test ( "gitlab.download should be an asyncFunction" , ( ) => {
21
+ assert . equal ( is . func ( gitlab . download ) , true ) ;
22
+ assert . equal ( is . asyncFunction ( gitlab . download ) , true ) ;
27
23
} ) ;
28
24
29
- test ( "gitlab.downloadAndExtract should be an asyncFunction" , ( tape ) => {
30
- tape . true ( is . func ( gitlab . downloadAndExtract ) ) ;
31
- tape . true ( is . asyncFunction ( gitlab . downloadAndExtract ) ) ;
32
-
33
- tape . end ( ) ;
25
+ test ( "gitlab.downloadAndExtract should be an asyncFunction" , ( ) => {
26
+ assert . equal ( is . func ( gitlab . downloadAndExtract ) , true ) ;
27
+ assert . equal ( is . asyncFunction ( gitlab . downloadAndExtract ) , true ) ;
34
28
} ) ;
35
29
36
- test ( "download must throw: repository must be a string!" , async ( tape ) => {
37
- tape . plan ( 2 ) ;
38
-
39
- try {
40
- await gitlab . download ( 10 ) ;
41
- }
42
- catch ( error ) {
43
- tape . strictEqual ( error . name , "TypeError" ) ;
44
- tape . strictEqual ( error . message , "repository must be a string!" ) ;
45
- }
46
-
47
- tape . end ( ) ;
30
+ test ( "download must throw: repository must be a string!" , async ( ) => {
31
+ assert . rejects (
32
+ async ( ) => await gitlab . download ( 10 ) ,
33
+ {
34
+ name : "TypeError" ,
35
+ message : "repository must be a string!"
36
+ }
37
+ ) ;
48
38
} ) ;
49
39
50
- test ( "extract tar.gz at in the current working dir" , async ( tape ) => {
40
+ test ( "extract tar.gz at in the current working dir" , async ( ) => {
51
41
const { location } = await gitlab . download ( "polychromatic.plombier-chauffagiste" ) ;
52
42
53
43
await fs . access ( location ) ;
54
- tape . strictEqual ( path . extname ( location ) , ".gz" ) ;
55
-
56
- tape . end ( ) ;
44
+ assert . strictEqual ( path . extname ( location ) , ".gz" ) ;
57
45
} ) ;
58
46
59
- test ( "download and extract a public gitlab repository" , async ( tape ) => {
47
+ test ( "download and extract a public gitlab repository" , async ( ) => {
60
48
const { location } = await gitlab . downloadAndExtract ( "polychromatic.plombier-chauffagiste" , {
61
49
dest : kDownloadDir
62
50
} ) ;
63
51
64
- await fs . access ( location ) ;
65
- tape . pass ( ) ;
66
-
67
- tape . end ( ) ;
52
+ await assert . doesNotReject (
53
+ async ( ) => await fs . access ( location )
54
+ ) ;
68
55
} ) ;
69
56
70
- test ( "teardown" , async ( tape ) => {
57
+ test ( "teardown" , async ( ) => {
71
58
await new Promise ( ( resolve ) => setImmediate ( resolve ) ) ;
72
- await fs . rm ( kDownloadDir , { recursive : true , force : true } ) ;
73
59
74
- try {
75
- await fs . unlink ( path . join ( process . cwd ( ) , "plombier-chauffagiste-master.tar.gz" ) ) ;
76
- }
77
- catch ( err ) {
78
- // do nothing
79
- }
80
- finally {
81
- tape . end ( ) ;
82
- }
60
+ await assert . doesNotReject (
61
+ async ( ) => await fs . rm ( kDownloadDir , { recursive : true , force : true } )
62
+ ) ;
63
+
64
+ await assert . doesNotReject (
65
+ async ( ) => await fs . unlink ( path . join ( process . cwd ( ) , "plombier-chauffagiste-master.tar.gz" ) )
66
+ ) ;
83
67
} ) ;
0 commit comments