aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sra-report/test/postman_collection_v0_test.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-03-13 02:00:08 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-03-14 06:54:33 +0800
commitb08374f0ba2d1c163f1c8d75a06f642101e1e15d (patch)
treea09e61a6131cc0dbd35fc963f09b1a774ca61959 /packages/sra-report/test/postman_collection_v0_test.ts
parentdf9e7385ad86a16db195fa75db18dd6ee21eedf1 (diff)
downloaddexon-sol-tools-b08374f0ba2d1c163f1c8d75a06f642101e1e15d.tar
dexon-sol-tools-b08374f0ba2d1c163f1c8d75a06f642101e1e15d.tar.gz
dexon-sol-tools-b08374f0ba2d1c163f1c8d75a06f642101e1e15d.tar.bz2
dexon-sol-tools-b08374f0ba2d1c163f1c8d75a06f642101e1e15d.tar.lz
dexon-sol-tools-b08374f0ba2d1c163f1c8d75a06f642101e1e15d.tar.xz
dexon-sol-tools-b08374f0ba2d1c163f1c8d75a06f642101e1e15d.tar.zst
dexon-sol-tools-b08374f0ba2d1c163f1c8d75a06f642101e1e15d.zip
Add scaffolding for sra-report collection unit tests
Diffstat (limited to 'packages/sra-report/test/postman_collection_v0_test.ts')
-rw-r--r--packages/sra-report/test/postman_collection_v0_test.ts76
1 files changed, 76 insertions, 0 deletions
diff --git a/packages/sra-report/test/postman_collection_v0_test.ts b/packages/sra-report/test/postman_collection_v0_test.ts
new file mode 100644
index 000000000..dfb16b10d
--- /dev/null
+++ b/packages/sra-report/test/postman_collection_v0_test.ts
@@ -0,0 +1,76 @@
+import 'mocha';
+import * as nock from 'nock';
+
+import * as defaultRequestTokenPairsResponseJSON from './fixtures/v0/token_pairs/default_request.json';
+import * as malformedTokenPairsResponseJSON from './fixtures/v0/token_pairs/malformed.json';
+import * as tokenAAndTokenBParamsTokenPairsResponseJSON from './fixtures/v0/token_pairs/token_a_and_token_b_params.json';
+import * as tokenAParamTokenPairsResponseJSON from './fixtures/v0/token_pairs/token_a_param.json';
+import * as tokenBParamTokenPairsResponseJSON from './fixtures/v0/token_pairs/token_b_param.json';
+import { testRunner } from './test_runner';
+
+describe('Postman Collection v0', () => {
+ const testRelayerUrl = 'https://example.com';
+ const nockScope = nock(testRelayerUrl);
+ afterEach(() => {
+ nock.cleanAll();
+ });
+ describe('GET /token_pairs', () => {
+ const postmanCollectionFolderName = 'GET /token_pairs';
+ const resourcePath = '/token_pairs';
+ describe('default request', () => {
+ const postmanCollectionRequestName = 'default request';
+ const nockInterceptor = nockScope.get(resourcePath);
+ testRunner.runContentTypeTests(nockInterceptor, postmanCollectionFolderName, postmanCollectionRequestName);
+ testRunner.runSchemaTests(
+ nockInterceptor,
+ postmanCollectionFolderName,
+ postmanCollectionRequestName,
+ malformedTokenPairsResponseJSON,
+ defaultRequestTokenPairsResponseJSON,
+ );
+ });
+ describe('tokenA param', () => {
+ const postmanCollectionRequestName = 'tokenA param';
+ const nockInterceptor = nockScope.get(resourcePath).query({
+ tokenA: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
+ });
+ testRunner.runContentTypeTests(nockInterceptor, postmanCollectionFolderName, postmanCollectionRequestName);
+ testRunner.runSchemaTests(
+ nockInterceptor,
+ postmanCollectionFolderName,
+ postmanCollectionRequestName,
+ malformedTokenPairsResponseJSON,
+ tokenAParamTokenPairsResponseJSON,
+ );
+ });
+ describe('tokenB param', () => {
+ const postmanCollectionRequestName = 'tokenB param';
+ const nockInterceptor = nockScope.get(resourcePath).query({
+ tokenB: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
+ });
+ testRunner.runContentTypeTests(nockInterceptor, postmanCollectionFolderName, postmanCollectionRequestName);
+ testRunner.runSchemaTests(
+ nockInterceptor,
+ postmanCollectionFolderName,
+ postmanCollectionRequestName,
+ malformedTokenPairsResponseJSON,
+ tokenBParamTokenPairsResponseJSON,
+ );
+ });
+ describe('tokenA and tokenB params', () => {
+ const postmanCollectionRequestName = 'tokenA and tokenB params';
+ const nockInterceptor = nockScope.get(resourcePath).query({
+ tokenA: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
+ tokenB: '0xe41d2489571d322189246dafa5ebde1f4699f498',
+ });
+ testRunner.runContentTypeTests(nockInterceptor, postmanCollectionFolderName, postmanCollectionRequestName);
+ testRunner.runSchemaTests(
+ nockInterceptor,
+ postmanCollectionFolderName,
+ postmanCollectionRequestName,
+ malformedTokenPairsResponseJSON,
+ tokenAAndTokenBParamsTokenPairsResponseJSON,
+ );
+ });
+ });
+});