|
4 | 4 | * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0 |
5 | 5 | */ |
6 | 6 |
|
7 | | -import {ux, Config} from '@oclif/core'; |
| 7 | +import {ux} from '@oclif/core'; |
8 | 8 | import {expect} from 'chai'; |
| 9 | +import {afterEach, beforeEach} from 'mocha'; |
9 | 10 | import sinon from 'sinon'; |
10 | 11 | import DocsSearch from '../../../src/commands/docs/search.js'; |
11 | | -import {isolateConfig, restoreConfig} from '../../helpers/config-isolation.js'; |
12 | | -import {stubParse} from '../../helpers/stub-parse.js'; |
| 12 | +import {createIsolatedConfigHooks, createTestCommand} from '../../helpers/test-setup.js'; |
13 | 13 |
|
14 | 14 | describe('docs search', () => { |
15 | | - let config: Config; |
| 15 | + const hooks = createIsolatedConfigHooks(); |
16 | 16 |
|
17 | | - async function createCommand(flags: Record<string, unknown>, args: Record<string, unknown>) { |
18 | | - const command: any = new DocsSearch([], config); |
19 | | - stubParse(command, flags, args); |
20 | | - await command.init(); |
21 | | - return command; |
22 | | - } |
| 17 | + beforeEach(hooks.beforeEach); |
23 | 18 |
|
24 | | - beforeEach(async () => { |
25 | | - isolateConfig(); |
26 | | - config = await Config.load(); |
27 | | - }); |
| 19 | + afterEach(hooks.afterEach); |
28 | 20 |
|
29 | | - afterEach(() => { |
30 | | - sinon.restore(); |
31 | | - restoreConfig(); |
32 | | - }); |
| 21 | + async function createCommand(flags: Record<string, unknown>, args: Record<string, unknown>) { |
| 22 | + return createTestCommand(DocsSearch, hooks.getConfig(), flags, args); |
| 23 | + } |
33 | 24 |
|
34 | 25 | it('errors when query is missing in search mode', async () => { |
35 | 26 | const command: any = await createCommand({}, {}); |
|
0 commit comments