Skip to content

Commit d9520f7

Browse files
committed
isolation of tests
1 parent 2892685 commit d9520f7

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

packages/b2c-cli/test/commands/scapi/schemas/get.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,25 @@
55
*/
66
import {runCommand} from '@oclif/test';
77
import {expect} from 'chai';
8+
import {createIsolatedEnvHooks} from '../../../helpers/test-setup.js';
89

910
describe('scapi schemas get', () => {
11+
const hooks = createIsolatedEnvHooks();
12+
13+
beforeEach(hooks.beforeEach);
14+
15+
afterEach(hooks.afterEach);
16+
1017
it('shows help without errors', async () => {
1118
const {error} = await runCommand('scapi schemas get --help');
1219
expect(error).to.be.undefined;
1320
});
1421

1522
it('requires tenant-id flag', async () => {
16-
const {error} = await runCommand('scapi schemas get shopper products v1');
23+
// Provide mock OAuth credentials so we get past OAuth validation to tenant-id validation
24+
const {error} = await runCommand(
25+
'scapi schemas get shopper products v1 --client-id test-client --short-code testcode',
26+
);
1727
expect(error).to.not.be.undefined;
1828
expect(error?.message).to.include('tenant-id');
1929
});

packages/b2c-cli/test/commands/scapi/schemas/list.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@
55
*/
66
import {runCommand} from '@oclif/test';
77
import {expect} from 'chai';
8+
import {createIsolatedEnvHooks} from '../../../helpers/test-setup.js';
89

910
describe('scapi schemas list', () => {
11+
const hooks = createIsolatedEnvHooks();
12+
13+
beforeEach(hooks.beforeEach);
14+
15+
afterEach(hooks.afterEach);
16+
1017
it('shows help without errors', async () => {
1118
const {error} = await runCommand('scapi schemas list --help');
1219
expect(error).to.be.undefined;
1320
});
1421

1522
it('requires tenant-id flag', async () => {
16-
const {error} = await runCommand('scapi schemas list');
23+
// Provide mock OAuth credentials so we get past OAuth validation to tenant-id validation
24+
const {error} = await runCommand('scapi schemas list --client-id test-client --short-code testcode');
1725
expect(error).to.not.be.undefined;
1826
expect(error?.message).to.include('tenant-id');
1927
});

0 commit comments

Comments
 (0)