aboutsummaryrefslogtreecommitdiffstats
path: root/packages/json-schemas/test
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/json-schemas/test
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/json-schemas/test')
-rw-r--r--packages/json-schemas/test/schema_test.ts30
1 files changed, 29 insertions, 1 deletions
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 = [