|
1 | 1 | import { expect, rs, test } from 'rstack/test'; |
2 | | -import { normalizeRstackConfig, type RstackConfig } from '../../src/config.ts'; |
| 2 | +import { normalizeRstackConfig } from '../../src/config.ts'; |
3 | 3 | import { resolveConfigLayers } from '../../src/configLayers.ts'; |
4 | 4 |
|
5 | 5 | test('preserves tool definitions without resolving factories or inheritance', () => { |
6 | 6 | const app = rs.fn(() => ({})); |
7 | | - const staged = rs.fn(() => ['rs lint']); |
8 | | - const shared: RstackConfig = { |
| 7 | + const config = normalizeRstackConfig({ |
9 | 8 | extends: [{ fmt: { singleQuote: true } }], |
10 | 9 | app, |
11 | | - staged, |
12 | | - }; |
| 10 | + lint: [], |
| 11 | + }); |
13 | 12 |
|
14 | | - expect(normalizeRstackConfig(shared)).toEqual({ app, staged }); |
15 | | - expect(shared.extends).toEqual([{ fmt: { singleQuote: true } }]); |
| 13 | + expect(config).toEqual({ app, lint: [] }); |
16 | 14 | expect(app).not.toHaveBeenCalled(); |
17 | | - expect(staged).not.toHaveBeenCalled(); |
18 | 15 | }); |
19 | 16 |
|
20 | | -test('resolves sync and async lint factories lazily with tool exports', async () => { |
21 | | - const syncLint = rs.fn((lint: typeof import('@rslint/core')) => [ |
22 | | - lint.js.configs.recommended, |
23 | | - ]); |
24 | | - const asyncLint = rs.fn((lint: typeof import('@rslint/core')) => |
25 | | - Promise.resolve([lint.ts.configs.recommended]), |
| 17 | +test('wraps lint factories lazily with tool exports', async () => { |
| 18 | + const lint = rs.fn((lint: typeof import('@rslint/core')) => |
| 19 | + Promise.resolve([lint.js.configs.recommended]), |
26 | 20 | ); |
27 | | - const shared: RstackConfig[] = [ |
28 | | - { lint: [] }, |
29 | | - { lint: syncLint }, |
30 | | - { lint: asyncLint }, |
31 | | - ]; |
32 | | - const configs = shared.map(normalizeRstackConfig); |
33 | | - |
34 | | - expect(syncLint).not.toHaveBeenCalled(); |
35 | | - expect(asyncLint).not.toHaveBeenCalled(); |
36 | | - expect(shared[1].lint).toBe(syncLint); |
| 21 | + const config = normalizeRstackConfig({ lint }); |
37 | 22 |
|
38 | | - const resolved = await resolveConfigLayers(configs, 'lint'); |
39 | | - const { js, ts } = await import('@rslint/core'); |
| 23 | + expect(lint).not.toHaveBeenCalled(); |
40 | 24 |
|
41 | | - expect(resolved).toEqual([ |
42 | | - [], |
| 25 | + const { js } = await import('@rslint/core'); |
| 26 | + expect(await resolveConfigLayers([config], 'lint')).toEqual([ |
43 | 27 | [js.configs.recommended], |
44 | | - [ts.configs.recommended], |
45 | 28 | ]); |
46 | 29 | }); |
0 commit comments