@@ -24,30 +24,21 @@ describe('processProtectedData > fetchOrdersUnderMaxPrice', () => {
2424 return Promise . resolve ( MOCK_APP_ORDER ) ;
2525 } ) ;
2626
27- const mockFetchWorkerpoolOrderbook : any = jest
28- . fn ( )
29- . mockImplementationOnce ( ( ) => {
30- return Promise . resolve ( MOCK_WORKERPOOL_ORDER ) ;
31- } ) ;
32-
3327 beforeEach ( ( ) => {
3428 iexec . orderbook . fetchDatasetOrderbook = mockFetchDatasetOrderbook ;
3529 iexec . orderbook . fetchAppOrderbook = mockFetchAppOrderbook ;
36- iexec . orderbook . fetchWorkerpoolOrderbook = mockFetchWorkerpoolOrderbook ;
3730 } ) ;
3831
3932 it ( 'should return the first free orders if maxPrice is undefined' , ( ) => {
4033 const maxPrice = undefined ;
4134 const result = fetchOrdersUnderMaxPrice (
4235 MOCK_DATASET_ORDER ,
4336 MOCK_APP_ORDER ,
44- MOCK_WORKERPOOL_ORDER ,
4537 maxPrice
4638 ) ;
4739 expect ( result ) . toEqual ( {
4840 datasetorder : MOCK_DATASET_ORDER . orders [ 0 ] ?. order ,
4941 apporder : MOCK_APP_ORDER . orders [ 0 ] ?. order ,
50- workerpoolorder : MOCK_WORKERPOOL_ORDER . orders [ 0 ] ?. order ,
5142 } ) ;
5243 } ) ;
5344
@@ -56,13 +47,10 @@ describe('processProtectedData > fetchOrdersUnderMaxPrice', () => {
5647 const result = fetchOrdersUnderMaxPrice (
5748 MOCK_DATASET_ORDER ,
5849 MOCK_APP_ORDER ,
59- MOCK_WORKERPOOL_ORDER ,
6050 maxPrice
6151 ) ;
6252 const totalPrice =
63- result . datasetorder . datasetprice +
64- result . apporder . appprice +
65- result . workerpoolorder . workerpoolprice ;
53+ result . datasetorder . datasetprice + result . apporder . appprice ;
6654 expect ( totalPrice ) . toBeLessThanOrEqual ( maxPrice ) ;
6755 } ) ;
6856
@@ -77,15 +65,10 @@ describe('processProtectedData > fetchOrdersUnderMaxPrice', () => {
7765 orders : MOCK_APP_ORDER . orders . slice ( 1 ) ,
7866 count : MOCK_APP_ORDER . count - 1 ,
7967 } ;
80- const MOCK_WORKERPOOL_ORDER_WITHOUT_FIRST_ORDER = {
81- orders : MOCK_WORKERPOOL_ORDER . orders . slice ( 1 ) ,
82- count : MOCK_WORKERPOOL_ORDER . count - 1 ,
83- } ;
8468 expect ( ( ) =>
8569 fetchOrdersUnderMaxPrice (
8670 MOCK_DATASET_ORDER_WITHOUT_FIRST_ORDER ,
8771 MOCK_APP_ORDER_WITHOUT_FIRST_ORDER ,
88- MOCK_WORKERPOOL_ORDER_WITHOUT_FIRST_ORDER ,
8972 maxPrice
9073 )
9174 ) . toThrow (
@@ -95,34 +78,13 @@ describe('processProtectedData > fetchOrdersUnderMaxPrice', () => {
9578
9679 it ( 'should throw an error when dataset orderbook is not provided' , ( ) => {
9780 expect ( ( ) =>
98- fetchOrdersUnderMaxPrice (
99- EMPTY_ORDER_BOOK ,
100- MOCK_APP_ORDER ,
101- MOCK_WORKERPOOL_ORDER ,
102- 10
103- )
81+ fetchOrdersUnderMaxPrice ( EMPTY_ORDER_BOOK , MOCK_APP_ORDER , 10 )
10482 ) . toThrow ( 'No dataset orders found' ) ;
10583 } ) ;
10684
10785 it ( 'should throw an error when application orderbook is not provided' , ( ) => {
10886 expect ( ( ) =>
109- fetchOrdersUnderMaxPrice (
110- MOCK_DATASET_ORDER ,
111- EMPTY_ORDER_BOOK ,
112- MOCK_WORKERPOOL_ORDER ,
113- 10
114- )
87+ fetchOrdersUnderMaxPrice ( MOCK_DATASET_ORDER , EMPTY_ORDER_BOOK , 10 )
11588 ) . toThrow ( 'No app orders found' ) ;
11689 } ) ;
117-
118- it ( 'should throw an error when workerpool orderbook is not provided' , ( ) => {
119- expect ( ( ) =>
120- fetchOrdersUnderMaxPrice (
121- MOCK_DATASET_ORDER ,
122- MOCK_APP_ORDER ,
123- EMPTY_ORDER_BOOK ,
124- 10
125- )
126- ) . toThrow ( 'No workerpool orders found' ) ;
127- } ) ;
12890} ) ;
0 commit comments