15 lines
707 B
JavaScript
15 lines
707 B
JavaScript
const assert = require('node:assert/strict');
|
|
const { test } = require('node:test');
|
|
const fs = require('node:fs');
|
|
const vm = require('node:vm');
|
|
const factory = vm.runInNewContext(fs.readFileSync('src/services/fusion/sr-details.js', 'utf8') + '\ncreateFusionSrDetails');
|
|
test('Internal SR background returns 401 without opening any tab or retrying', async () => {
|
|
let calls = 0;
|
|
const api = factory({
|
|
fetchJson: async () => { calls++; throw Object.assign(new Error('Unauthorized'), {httpStatus:401}); },
|
|
tabsCreate: () => assert.fail('Internal SR must not open a tab')
|
|
});
|
|
await assert.rejects(api.requestInternalServiceRequest({srId:'123'}), /Unauthorized/);
|
|
assert.equal(calls,1);
|
|
});
|