aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sra-report/test/postman_collection_v0_test.ts
blob: 5a2fc2520f3297b38847213d743b228e5566e9ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import 'make-promises-safe';
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,
            );
        });
    });
});