also looking at this
feat: observe verified metadata before persistence
#1
8 files
+807
-21
| @@ -4,6 +4,7 @@ import fs from 'fs'; | ||
| 4 | 4 | import nock from 'nock'; |
| 5 | 5 | import os from 'os'; |
| 6 | 6 | import path from 'path'; |
| 7 | import { MetadataVerificationError } from '../src/error'; | |
| 7 | 8 | import { Updater, UpdaterOptions } from '../src/updater'; |
| 8 | 9 | |
| 9 | 10 | describe('Updater', () => { |
| @@ -91,9 +92,15 @@ describe('Updater', () => { | ||
| 91 | 92 | nock(baseURL).get('/metadata/2.root.json').reply(200, {}); |
| 92 | 93 | }); |
| 93 | 94 | |
| 94 | it('resolves with no error', async () => { | |
| 95 | it('rejects with the verified role and original validation cause', async () => { | |
| 95 | 96 | const updater = new Updater(options); |
| 96 | await expect(updater.refresh()).rejects.toThrow(TypeError); | |
| 97 | const refresh = updater.refresh(); | |
| 98 | await expect(refresh).rejects.toBeInstanceOf(MetadataVerificationError); | |
| 99 | await expect(refresh).rejects.toHaveProperty('role', 'root'); | |
| 100 | await expect(refresh).rejects.toHaveProperty( | |
| 101 | 'cause', | |
| 102 | expect.any(TypeError) | |
| 103 | ); | |
| 97 | 104 | }); |
| 98 | 105 | }); |
| 99 | 106 | }); |