Add paginated collection test case
This commit is contained in:
parent
4aff9515d8
commit
63e869f6d0
@ -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'],
|
||||
};
|
||||
|
@ -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';
|
||||
|
@ -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 = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user