aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-08-01 08:04:22 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-08-01 08:04:22 +0800
commit63e869f6d01663a22773d244920362921dbcdcdc (patch)
treebaa38b03db88fa1e057fe5188cc1f86d2e1f2a1a /packages
parent4aff9515d807feb5fc30431d109d503a6c52f0cd (diff)
downloaddexon-sol-tools-63e869f6d01663a22773d244920362921dbcdcdc.tar
dexon-sol-tools-63e869f6d01663a22773d244920362921dbcdcdc.tar.gz
dexon-sol-tools-63e869f6d01663a22773d244920362921dbcdcdc.tar.bz2
dexon-sol-tools-63e869f6d01663a22773d244920362921dbcdcdc.tar.lz
dexon-sol-tools-63e869f6d01663a22773d244920362921dbcdcdc.tar.xz
dexon-sol-tools-63e869f6d01663a22773d244920362921dbcdcdc.tar.zst
dexon-sol-tools-63e869f6d01663a22773d244920362921dbcdcdc.zip
Add paginated collection test case
Diffstat (limited to 'packages')
-rw-r--r--packages/json-schemas/schemas/paginated_collection_schema.ts6
-rw-r--r--packages/json-schemas/src/schemas.ts2
-rw-r--r--packages/json-schemas/test/schema_test.ts30
3 files changed, 33 insertions, 5 deletions
diff --git a/packages/json-schemas/schemas/paginated_collection_schema.ts b/packages/json-schemas/schemas/paginated_collection_schema.ts
index 2c29ef4e0..abd86f1ef 100644
--- a/packages/json-schemas/schemas/paginated_collection_schema.ts
+++ b/packages/json-schemas/schemas/paginated_collection_schema.ts
@@ -2,9 +2,9 @@ export const paginatedCollectionSchema = {
id: '/PaginatedCollection',
type: 'object',
properties: {
- total: { $ref: '/Number' },
- perPage: { $ref: '/Number' },
- page: { $ref: '/Number' },
+ total: { type: 'number' },
+ perPage: { type: 'number' },
+ page: { type: 'number' },
},
required: ['total', 'perPage', 'page'],
};
diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts
index defe55bda..97aa486f2 100644
--- a/packages/json-schemas/src/schemas.ts
+++ b/packages/json-schemas/src/schemas.ts
@@ -17,6 +17,7 @@ import {
import { relayerApiErrorResponseSchema } from '../schemas/relayer_api_error_response_schema';
import { relayerApiOrderConfigPayloadSchema } from '../schemas/relayer_api_order_config_payload_schema';
import { relayerApiOrderConfigResponseSchema } from '../schemas/relayer_api_order_config_response_schema';
+import { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema';
import { relayerApiOrderBookResponseSchema } from '../schemas/relayer_api_orderbook_response_schema';
import {
relayerApiOrdersChannelSubscribePayload,
@@ -25,7 +26,6 @@ import {
import { relayerApiOrdersChannelUpdateSchema } from '../schemas/relayer_api_orders_channel_update_response_schema';
import { relayerApiOrdersResponseSchema } from '../schemas/relayer_api_orders_response_schema';
import { relayerApiOrdersSchema } from '../schemas/relayer_api_orders_schema';
-import { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema';
import { signedOrdersSchema } from '../schemas/signed_orders_schema';
import { tokenSchema } from '../schemas/token_schema';
import { jsNumber, txDataSchema } from '../schemas/tx_data_schema';
diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts
index a6bbf12e6..03c0e950b 100644
--- a/packages/json-schemas/test/schema_test.ts
+++ b/packages/json-schemas/test/schema_test.ts
@@ -167,6 +167,34 @@ describe('Schema', () => {
validateAgainstSchema(testCases, tokenSchema, shouldFail);
});
});
+ describe('#paginatedCollectionSchema', () => {
+ const paginatedResponse = {
+ total: 100,
+ perPage: 10,
+ page: 3,
+ };
+ it('should validate valid paginated collections', () => {
+ const testCases = [paginatedResponse];
+ validateAgainstSchema(testCases, paginatedCollectionSchema);
+ });
+ it('should fail for invalid paginated collections', () => {
+ const paginatedCollectionNoTotal = {
+ page: 10,
+ perPage: 2,
+ };
+ const paginatedCollectionNoPerPage = {
+ page: 10,
+ total: 100,
+ };
+ const paginatedCollectionNoPage = {
+ total: 10,
+ perPage: 20,
+ };
+ const testCases = [{}, paginatedCollectionNoPage, paginatedCollectionNoPerPage, paginatedCollectionNoTotal];
+ const shouldFail = true;
+ validateAgainstSchema(testCases, paginatedCollectionSchema, shouldFail);
+ });
+ });
describe('order including schemas', () => {
const order = {
makerAddress: NULL_ADDRESS,
@@ -329,7 +357,7 @@ describe('Schema', () => {
asks: [signedOrder, signedOrder],
},
];
- validateAgainstSchema(testCases, relayerApiOrdersResponseSchema);
+ validateAgainstSchema(testCases, relayerApiOrderBookResponseSchema);
});
it('should fail for invalid order fill requests', () => {
const testCases = [