File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,16 @@ jest.retryTimes(3);
6
6
7
7
describe ( 'NodeConnection' , ( ) => {
8
8
let connection : AleoNetworkClient ;
9
+ let windowFetchSpy : jest . Spied < typeof fetch > ;
9
10
10
11
beforeEach ( ( ) => {
11
12
connection = new AleoNetworkClient ( "https://api.explorer.aleo.org/v1" ) ;
13
+ windowFetchSpy = jest . spyOn ( globalThis , 'fetch' ) ;
14
+ } ) ;
15
+
16
+ afterEach ( ( ) => {
17
+ jest . restoreAllMocks ( ) ;
18
+ windowFetchSpy = null ;
12
19
} ) ;
13
20
14
21
describe ( 'setAccount' , ( ) => {
@@ -76,6 +83,25 @@ describe('NodeConnection', () => {
76
83
const latestBlock = await connection . getLatestBlock ( ) ;
77
84
expect ( typeof ( latestBlock as Block ) . block_hash ) . toBe ( 'string' ) ;
78
85
} , 60000 ) ;
86
+
87
+ it ( 'should set the X-Aleo-SDK-Version header' , async ( ) => {
88
+ expect ( windowFetchSpy . mock . calls ) . toStrictEqual ( [ ] ) ;
89
+
90
+ await connection . getLatestBlock ( ) ;
91
+
92
+ expect ( windowFetchSpy . mock . calls ) . toStrictEqual ( [
93
+ [
94
+ "https://api.explorer.aleo.org/v1/testnet3/latest/block" ,
95
+ {
96
+ "headers" : {
97
+ // @TODO : Run the Jest tests on the compiled Rollup code,
98
+ // so that way the version is properly replaced.
99
+ "X-Aleo-SDK-Version" : "%%VERSION%%"
100
+ }
101
+ }
102
+ ] ,
103
+ ] ) ;
104
+ } , 60000 ) ;
79
105
} ) ;
80
106
81
107
describe ( 'getLatestCommittee' , ( ) => {
You can’t perform that action at this time.
0 commit comments