|
10 | 10 | * governing permissions and limitations under the License. |
11 | 11 | */ |
12 | 12 | /* eslint-env mocha */ |
| 13 | +/* eslint-disable no-console */ |
13 | 14 | const assert = require('assert'); |
14 | 15 | const querystring = require('querystring'); |
15 | 16 | const dataSource = require('../src/data-source.js'); |
@@ -57,97 +58,113 @@ describe('Data Source Tests', () => { |
57 | 58 | }); |
58 | 59 |
|
59 | 60 | it('src parameters allows for different scheme', () => { |
60 | | - assert.equal(dataSource({ |
61 | | - url: `https://www.example.com/foo?${querystring.stringify({ |
62 | | - src: 'onedrive://drives/123123/items/234234', |
63 | | - })}`, |
64 | | - }, context), |
65 | | - 'onedrive://drives/123123/items/234234'); |
| 61 | + assert.equal( |
| 62 | + dataSource({ |
| 63 | + url: `https://www.example.com/foo?${querystring.stringify({ |
| 64 | + src: 'onedrive://drives/123123/items/234234', |
| 65 | + })}`, |
| 66 | + }, context), |
| 67 | + 'onedrive://drives/123123/items/234234', |
| 68 | + ); |
66 | 69 | }); |
67 | 70 |
|
68 | 71 | it('returns data source for `src` parameter', () => { |
69 | | - assert.equal(dataSource({ |
70 | | - url: `https://www.example.com/foo?${querystring.stringify({ |
71 | | - src: 'https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2', |
72 | | - hlx_limit: '1', |
73 | | - foo: 'bar', |
74 | | - })}`, |
75 | | - }, context), |
76 | | - 'https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2'); |
| 72 | + assert.equal( |
| 73 | + dataSource({ |
| 74 | + url: `https://www.example.com/foo?${querystring.stringify({ |
| 75 | + src: 'https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2', |
| 76 | + hlx_limit: '1', |
| 77 | + foo: 'bar', |
| 78 | + })}`, |
| 79 | + }, context), |
| 80 | + 'https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2', |
| 81 | + ); |
77 | 82 | }); |
78 | 83 |
|
79 | 84 | it('returns data source for `src` parameter with different scheme', () => { |
80 | | - assert.equal(dataSource({ |
81 | | - url: `https://www.example.com/foo?${querystring.stringify({ |
82 | | - src: 'onedrive://drives/1234/items/5677?a=1&b=2', |
83 | | - hlx_limit: '1', |
84 | | - foo: 'bar', |
85 | | - })}`, |
86 | | - }, context), |
87 | | - 'onedrive://drives/1234/items/5677?a=1&b=2'); |
| 85 | + assert.equal( |
| 86 | + dataSource({ |
| 87 | + url: `https://www.example.com/foo?${querystring.stringify({ |
| 88 | + src: 'onedrive://drives/1234/items/5677?a=1&b=2', |
| 89 | + hlx_limit: '1', |
| 90 | + foo: 'bar', |
| 91 | + })}`, |
| 92 | + }, context), |
| 93 | + 'onedrive://drives/1234/items/5677?a=1&b=2', |
| 94 | + ); |
88 | 95 | }); |
89 | 96 |
|
90 | 97 | it('returns data source for backward compat path parameter with no query', () => { |
91 | | - assert.equal(dataSource({ |
92 | | - url: 'https://www.example.com/foo', |
93 | | - }, { |
94 | | - log, |
95 | | - pathInfo: { |
96 | | - suffix: '/https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2', |
97 | | - }, |
98 | | - }), |
99 | | - 'https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2'); |
| 98 | + assert.equal( |
| 99 | + dataSource({ |
| 100 | + url: 'https://www.example.com/foo', |
| 101 | + }, { |
| 102 | + log, |
| 103 | + pathInfo: { |
| 104 | + suffix: '/https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2', |
| 105 | + }, |
| 106 | + }), |
| 107 | + 'https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2', |
| 108 | + ); |
100 | 109 | }); |
101 | 110 |
|
102 | 111 | it('returns data source for backward compat path parameter and params', () => { |
103 | | - assert.equal(dataSource({ |
104 | | - url: `https://www.example.com/foo?${querystring.stringify({ |
105 | | - a: 1, |
106 | | - b: 2, |
107 | | - hlx_limit: 1, |
108 | | - })}`, |
109 | | - }, { |
110 | | - log, |
111 | | - pathInfo: { |
112 | | - suffix: '/https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500', |
113 | | - }, |
114 | | - }), |
115 | | - 'https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2'); |
| 112 | + assert.equal( |
| 113 | + dataSource({ |
| 114 | + url: `https://www.example.com/foo?${querystring.stringify({ |
| 115 | + a: 1, |
| 116 | + b: 2, |
| 117 | + hlx_limit: 1, |
| 118 | + })}`, |
| 119 | + }, { |
| 120 | + log, |
| 121 | + pathInfo: { |
| 122 | + suffix: '/https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500', |
| 123 | + }, |
| 124 | + }), |
| 125 | + 'https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2', |
| 126 | + ); |
116 | 127 | }); |
117 | 128 |
|
118 | 129 | it('returns data source for escaped path', () => { |
119 | | - assert.equal(dataSource({ |
120 | | - url: 'https://www.example.com/foo', |
121 | | - }, { |
122 | | - log, |
123 | | - pathInfo: { |
124 | | - suffix: `/${querystring.escape('https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2')}`, |
125 | | - }, |
126 | | - }), |
127 | | - 'https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2'); |
| 130 | + assert.equal( |
| 131 | + dataSource({ |
| 132 | + url: 'https://www.example.com/foo', |
| 133 | + }, { |
| 134 | + log, |
| 135 | + pathInfo: { |
| 136 | + suffix: `/${querystring.escape('https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2')}`, |
| 137 | + }, |
| 138 | + }), |
| 139 | + 'https://adobeioruntime.net/api/v1/web/helix/helix-services/[email protected]/error500?a=1&b=2', |
| 140 | + ); |
128 | 141 | }); |
129 | 142 |
|
130 | 143 | it('returns data source for escaped and mangled path', () => { |
131 | | - assert.equal(dataSource({ |
132 | | - url: 'https://www.example.com/foo', |
133 | | - }, { |
134 | | - log, |
135 | | - pathInfo: { |
136 | | - suffix: '/https:%2F%2Fwww.youtube.com%2Fwatch%3Fv=TTCVn4EByfI', |
137 | | - }, |
138 | | - }), |
139 | | - 'https://www.youtube.com/watch?v=TTCVn4EByfI'); |
| 144 | + assert.equal( |
| 145 | + dataSource({ |
| 146 | + url: 'https://www.example.com/foo', |
| 147 | + }, { |
| 148 | + log, |
| 149 | + pathInfo: { |
| 150 | + suffix: '/https:%2F%2Fwww.youtube.com%2Fwatch%3Fv=TTCVn4EByfI', |
| 151 | + }, |
| 152 | + }), |
| 153 | + 'https://www.youtube.com/watch?v=TTCVn4EByfI', |
| 154 | + ); |
140 | 155 | }); |
141 | 156 |
|
142 | 157 | it('returns data source for unescaped and mangled path', () => { |
143 | | - assert.equal(dataSource({ |
144 | | - url: 'https://www.example.com/foo', |
145 | | - }, { |
146 | | - log, |
147 | | - pathInfo: { |
148 | | - suffix: '/https:/www.youtube.com/watch?v=TTCVn4EByfI', |
149 | | - }, |
150 | | - }), |
151 | | - 'https://www.youtube.com/watch?v=TTCVn4EByfI'); |
| 158 | + assert.equal( |
| 159 | + dataSource({ |
| 160 | + url: 'https://www.example.com/foo', |
| 161 | + }, { |
| 162 | + log, |
| 163 | + pathInfo: { |
| 164 | + suffix: '/https:/www.youtube.com/watch?v=TTCVn4EByfI', |
| 165 | + }, |
| 166 | + }), |
| 167 | + 'https://www.youtube.com/watch?v=TTCVn4EByfI', |
| 168 | + ); |
152 | 169 | }); |
153 | 170 | }); |
0 commit comments