@@ -5,25 +5,10 @@ import path from "node:path";
5
5
import { afterEach , beforeEach , describe , it } from "node:test" ;
6
6
7
7
import { getTelemetryDir } from "@ignored/hardhat-vnext-core/global-dir" ;
8
- import {
9
- readJsonFile ,
10
- remove ,
11
- writeJsonFile ,
12
- } from "@ignored/hardhat-vnext-utils/fs" ;
8
+ import { readJsonFile , remove } from "@ignored/hardhat-vnext-utils/fs" ;
13
9
14
10
import { getAnalyticsClientId } from "../../../../../src/internal/cli/telemetry/analytics/utils.js" ;
15
11
16
- const CLIENT_ID = "test-client-id" ;
17
-
18
- async function createClientIdFile ( ) {
19
- const filePath = await getFilePath ( ) ;
20
- await writeJsonFile ( filePath , {
21
- analytics : {
22
- clientId : CLIENT_ID ,
23
- } ,
24
- } ) ;
25
- }
26
-
27
12
async function getClientIdFromFile ( ) {
28
13
const filePath = await getFilePath ( ) ;
29
14
const data : AnalyticsFile = await readJsonFile ( filePath ) ;
@@ -54,16 +39,13 @@ describe("telemetry/analytics/utils", () => {
54
39
55
40
// The analyticsClientId should be generate as uuid
56
41
assert . notEqual ( analyticsClientId , undefined ) ;
57
- assert . notEqual ( analyticsClientId , CLIENT_ID ) ;
58
42
// The analyticsClientId should also be saved in the file
59
43
assert . equal ( analyticsClientId , await getClientIdFromFile ( ) ) ;
60
- } ) ;
61
44
62
- it ( "should get the analyticsClientId from the file because it already exists" , async ( ) => {
63
- await createClientIdFile ( ) ;
64
- const analyticsClientId = await getClientIdFromFile ( ) ;
45
+ const sameAnalyticsClientId = await getAnalyticsClientId ( ) ;
65
46
66
- assert . equal ( analyticsClientId , CLIENT_ID ) ;
47
+ // The clientId should be the same if read again because it should have been stored
48
+ assert . equal ( sameAnalyticsClientId , analyticsClientId ) ;
67
49
} ) ;
68
50
} ) ;
69
51
} ) ;
0 commit comments