Skip to content

Commit d3ed89a

Browse files
chore: update unit tests
1 parent 6913617 commit d3ed89a

File tree

1 file changed

+90
-120
lines changed

1 file changed

+90
-120
lines changed

tests/unit/fetchMyContacts.test.ts

Lines changed: 90 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,24 @@ describe('fetchMyContacts', () => {
8383
dappWhitelistAddress: defaultConfig.whitelistSmartContract,
8484
});
8585
const userAddress = (await iexec.wallet.getAddress()).toLowerCase();
86-
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(
87-
1,
88-
'any',
89-
{
90-
app: defaultConfig.dappAddress.toLowerCase(),
91-
requester: userAddress,
92-
isAppStrict: true,
93-
isRequesterStrict: false,
94-
bulkOnly: false,
95-
pageSize: 1000,
96-
}
97-
);
98-
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(
99-
2,
100-
'any',
101-
{
102-
app: defaultConfig.whitelistSmartContract.toLowerCase(),
103-
requester: userAddress,
104-
isAppStrict: true,
105-
isRequesterStrict: false,
106-
bulkOnly: false,
107-
pageSize: 1000,
108-
}
109-
);
86+
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(1, {
87+
dataset: 'any',
88+
app: defaultConfig.dappAddress.toLowerCase(),
89+
requester: userAddress,
90+
isAppStrict: true,
91+
isRequesterStrict: false,
92+
bulkOnly: false,
93+
pageSize: 1000,
94+
});
95+
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(2, {
96+
dataset: 'any',
97+
app: defaultConfig.whitelistSmartContract.toLowerCase(),
98+
requester: userAddress,
99+
isAppStrict: true,
100+
isRequesterStrict: false,
101+
bulkOnly: false,
102+
pageSize: 1000,
103+
});
110104
});
111105

112106
it('should fetch granted access with isRequesterStrict param equal to true', async () => {
@@ -151,30 +145,24 @@ describe('fetchMyContacts', () => {
151145
isUserStrict: true,
152146
});
153147
const userAddress = (await iexec.wallet.getAddress()).toLowerCase();
154-
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(
155-
1,
156-
'any',
157-
{
158-
app: defaultConfig.dappAddress.toLowerCase(),
159-
requester: userAddress,
160-
isAppStrict: true,
161-
isRequesterStrict: true,
162-
bulkOnly: false,
163-
pageSize: 1000,
164-
}
165-
);
166-
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(
167-
2,
168-
'any',
169-
{
170-
app: defaultConfig.whitelistSmartContract.toLowerCase(),
171-
requester: userAddress,
172-
isAppStrict: true,
173-
isRequesterStrict: true,
174-
bulkOnly: false,
175-
pageSize: 1000,
176-
}
177-
);
148+
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(1, {
149+
dataset: 'any',
150+
app: defaultConfig.dappAddress.toLowerCase(),
151+
requester: userAddress,
152+
isAppStrict: true,
153+
isRequesterStrict: true,
154+
bulkOnly: false,
155+
pageSize: 1000,
156+
});
157+
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(2, {
158+
dataset: 'any',
159+
app: defaultConfig.whitelistSmartContract.toLowerCase(),
160+
requester: userAddress,
161+
isAppStrict: true,
162+
isRequesterStrict: true,
163+
bulkOnly: false,
164+
pageSize: 1000,
165+
});
178166
});
179167

180168
it('should include grantedAccess property in returned contacts', async () => {
@@ -282,30 +270,24 @@ describe('fetchMyContacts', () => {
282270
bulkOnly: false,
283271
});
284272
const userAddress = (await iexec.wallet.getAddress()).toLowerCase();
285-
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(
286-
1,
287-
'any',
288-
{
289-
app: defaultConfig.dappAddress.toLowerCase(),
290-
requester: userAddress,
291-
isAppStrict: true,
292-
isRequesterStrict: false,
293-
bulkOnly: false,
294-
pageSize: 1000,
295-
}
296-
);
297-
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(
298-
2,
299-
'any',
300-
{
301-
app: defaultConfig.whitelistSmartContract.toLowerCase(),
302-
requester: userAddress,
303-
isAppStrict: true,
304-
isRequesterStrict: false,
305-
bulkOnly: false,
306-
pageSize: 1000,
307-
}
308-
);
273+
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(1, {
274+
dataset: 'any',
275+
app: defaultConfig.dappAddress.toLowerCase(),
276+
requester: userAddress,
277+
isAppStrict: true,
278+
isRequesterStrict: false,
279+
bulkOnly: false,
280+
pageSize: 1000,
281+
});
282+
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(2, {
283+
dataset: 'any',
284+
app: defaultConfig.whitelistSmartContract.toLowerCase(),
285+
requester: userAddress,
286+
isAppStrict: true,
287+
isRequesterStrict: false,
288+
bulkOnly: false,
289+
pageSize: 1000,
290+
});
309291
});
310292

311293
it('should pass bulkOnly=true when fetching contacts', async () => {
@@ -352,30 +334,24 @@ describe('fetchMyContacts', () => {
352334
bulkOnly: true,
353335
});
354336
const userAddress = (await iexec.wallet.getAddress()).toLowerCase();
355-
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(
356-
1,
357-
'any',
358-
{
359-
app: defaultConfig.dappAddress.toLowerCase(),
360-
requester: userAddress,
361-
isAppStrict: true,
362-
isRequesterStrict: false,
363-
bulkOnly: true,
364-
pageSize: 1000,
365-
}
366-
);
367-
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(
368-
2,
369-
'any',
370-
{
371-
app: defaultConfig.whitelistSmartContract.toLowerCase(),
372-
requester: userAddress,
373-
isAppStrict: true,
374-
isRequesterStrict: false,
375-
bulkOnly: true,
376-
pageSize: 1000,
377-
}
378-
);
337+
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(1, {
338+
dataset: 'any',
339+
app: defaultConfig.dappAddress.toLowerCase(),
340+
requester: userAddress,
341+
isAppStrict: true,
342+
isRequesterStrict: false,
343+
bulkOnly: true,
344+
pageSize: 1000,
345+
});
346+
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(2, {
347+
dataset: 'any',
348+
app: defaultConfig.whitelistSmartContract.toLowerCase(),
349+
requester: userAddress,
350+
isAppStrict: true,
351+
isRequesterStrict: false,
352+
bulkOnly: true,
353+
pageSize: 1000,
354+
});
379355
});
380356

381357
it('should work with both isUserStrict and bulkOnly parameters', async () => {
@@ -424,30 +400,24 @@ describe('fetchMyContacts', () => {
424400
});
425401

426402
const userAddress = (await iexec.wallet.getAddress()).toLowerCase();
427-
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(
428-
1,
429-
'any',
430-
{
431-
app: defaultConfig.dappAddress.toLowerCase(),
432-
requester: userAddress,
433-
isAppStrict: true,
434-
isRequesterStrict: true,
435-
bulkOnly: true,
436-
pageSize: 1000,
437-
}
438-
);
439-
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(
440-
2,
441-
'any',
442-
{
443-
app: defaultConfig.whitelistSmartContract.toLowerCase(),
444-
requester: userAddress,
445-
isAppStrict: true,
446-
isRequesterStrict: true,
447-
bulkOnly: true,
448-
pageSize: 1000,
449-
}
450-
);
403+
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(1, {
404+
dataset: 'any',
405+
app: defaultConfig.dappAddress.toLowerCase(),
406+
requester: userAddress,
407+
isAppStrict: true,
408+
isRequesterStrict: true,
409+
bulkOnly: true,
410+
pageSize: 1000,
411+
});
412+
expect(iexec.orderbook.fetchDatasetOrderbook).toHaveBeenNthCalledWith(2, {
413+
dataset: 'any',
414+
app: defaultConfig.whitelistSmartContract.toLowerCase(),
415+
requester: userAddress,
416+
isAppStrict: true,
417+
isRequesterStrict: true,
418+
bulkOnly: true,
419+
pageSize: 1000,
420+
});
451421
});
452422
});
453423
});

0 commit comments

Comments
 (0)