■ ■ ■ ■ ■ ■
packages/public-api/src/clientApiRouter.test.ts
| skipped 84 lines |
85 | 85 | | webPageScan.id.toString() |
86 | 86 | | ); |
87 | 87 | | |
88 | | - | const url = '/client/getWebPageScan?batch=1&input=' + encodeURIComponent(JSON.stringify({'0' : siteUrl})); |
89 | | - | const responseGet = await api |
90 | | - | .get(url) |
91 | | - | .set('Origin', 'http://localhost:3000') |
92 | | - | .expect(200); |
93 | | - | expect(responseGet.body).toMatchObject([{ |
94 | | - | result: { |
95 | | - | data: { |
96 | | - | id: webPageScan.id.toString(), |
97 | | - | status: WebPageScan.Status.Pending, |
| 88 | + | const url = |
| 89 | + | '/client/getWebPageScan?batch=1&input=' + |
| 90 | + | encodeURIComponent(JSON.stringify({ '0': siteUrl })); |
| 91 | + | const responseGet = await api.get(url).set('Origin', 'http://localhost:3000').expect(200); |
| 92 | + | expect(responseGet.body).toMatchObject([ |
| 93 | + | { |
| 94 | + | result: { |
| 95 | + | data: { |
| 96 | + | id: webPageScan.id.toString(), |
| 97 | + | status: WebPageScan.Status.Pending, |
| 98 | + | }, |
98 | 99 | | }, |
99 | 100 | | }, |
100 | | - | }]); |
| 101 | + | ]); |
101 | 102 | | }); |
102 | 103 | | |
103 | 104 | | it('should return a cached scan if applicable', async () => { |
| skipped 29 lines |
133 | 134 | | |
134 | 135 | | expect(requestWebPageScanMock).toHaveBeenCalledTimes(0); |
135 | 136 | | |
136 | | - | const url = '/client/getWebPageScan?batch=1&input=' + encodeURIComponent(JSON.stringify({'0' : siteUrl})); |
137 | | - | const responseGet = await api |
138 | | - | .get(url) |
139 | | - | .set('Origin', 'http://localhost:3000') |
140 | | - | .expect(200); |
141 | | - | expect(responseGet.body).toMatchObject([{ |
142 | | - | result: { |
143 | | - | data: { |
144 | | - | id: existingScan.id.toString(), |
145 | | - | status: WebPageScan.Status.Processed, |
146 | | - | scanResult: { |
147 | | - | identifiedModuleMap: {}, |
148 | | - | identifiedPackages: [ |
149 | | - | { |
150 | | - | name: 'react', |
151 | | - | versionSet: ['17.0.0'], |
152 | | - | moduleIds: [], |
153 | | - | }, |
154 | | - | ], |
| 137 | + | const url = |
| 138 | + | '/client/getWebPageScan?batch=1&input=' + |
| 139 | + | encodeURIComponent(JSON.stringify({ '0': siteUrl })); |
| 140 | + | const responseGet = await api.get(url).set('Origin', 'http://localhost:3000').expect(200); |
| 141 | + | expect(responseGet.body).toMatchObject([ |
| 142 | + | { |
| 143 | + | result: { |
| 144 | + | data: { |
| 145 | + | id: existingScan.id.toString(), |
| 146 | + | status: WebPageScan.Status.Processed, |
| 147 | + | scanResult: { |
| 148 | + | identifiedModuleMap: {}, |
| 149 | + | identifiedPackages: [ |
| 150 | + | { |
| 151 | + | name: 'react', |
| 152 | + | versionSet: ['17.0.0'], |
| 153 | + | moduleIds: [], |
| 154 | + | }, |
| 155 | + | ], |
| 156 | + | }, |
155 | 157 | | }, |
156 | 158 | | }, |
157 | 159 | | }, |
158 | | - | }]); |
| 160 | + | ]); |
159 | 161 | | }); |
160 | 162 | | }); |
161 | 163 | | |