|
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 = { |
9 | | - extends: [{ fmt: { singleQuote: true } }], |
| 7 | + const config = normalizeRstackConfig({ |
| 8 | + extends: [ |
| 9 | + { |
| 10 | + fmt: { singleQuote: true }, |
| 11 | + }, |
| 12 | + ], |
10 | 13 | app, |
11 | | - staged, |
12 | | - }; |
| 14 | + lint: [], |
| 15 | + }); |
13 | 16 |
|
14 | | - expect(normalizeRstackConfig(shared)).toEqual({ app, staged }); |
15 | | - expect(shared.extends).toEqual([{ fmt: { singleQuote: true } }]); |
| 17 | + expect(config).toEqual({ app, lint: [] }); |
16 | 18 | expect(app).not.toHaveBeenCalled(); |
17 | | - expect(staged).not.toHaveBeenCalled(); |
18 | 19 | }); |
19 | 20 |
|
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]), |
| 21 | +test('wraps lint factories lazily with tool exports', async () => { |
| 22 | + const lint = rs.fn((lint: typeof import('@rslint/core')) => |
| 23 | + Promise.resolve([lint.js.configs.recommended]), |
26 | 24 | ); |
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); |
| 25 | + const config = normalizeRstackConfig({ lint }); |
37 | 26 |
|
38 | | - const resolved = await resolveConfigLayers(configs, 'lint'); |
39 | | - const { js, ts } = await import('@rslint/core'); |
| 27 | + expect(lint).not.toHaveBeenCalled(); |
40 | 28 |
|
41 | | - expect(resolved).toEqual([ |
42 | | - [], |
| 29 | + const { js } = await import('@rslint/core'); |
| 30 | + expect(await resolveConfigLayers([config], 'lint')).toEqual([ |
43 | 31 | [js.configs.recommended], |
44 | | - [ts.configs.recommended], |
45 | 32 | ]); |
46 | 33 | }); |
0 commit comments