(fs: {
existsSync: ReturnType<typeof vi.fn>
readFileSync: ReturnType<typeof vi.fn>
writeFile: ReturnType<typeof vi.fn>
ensureDirSync: ReturnType<typeof vi.fn>
})
| 2 | import { OutputEngine } from '../src/output-engine' |
| 3 | |
| 4 | function createEngine(fs: { |
| 5 | existsSync: ReturnType<typeof vi.fn> |
| 6 | readFileSync: ReturnType<typeof vi.fn> |
| 7 | writeFile: ReturnType<typeof vi.fn> |
| 8 | ensureDirSync: ReturnType<typeof vi.fn> |
| 9 | }) { |
| 10 | return new OutputEngine({ |
| 11 | paths: { root: ['styled-system'] }, |
| 12 | runtime: { |
| 13 | fs: { |
| 14 | existsSync: fs.existsSync, |
| 15 | readFileSync: fs.readFileSync, |
| 16 | writeFile: fs.writeFile, |
| 17 | ensureDirSync: fs.ensureDirSync, |
| 18 | }, |
| 19 | path: { |
| 20 | join: (...parts: string[]) => parts.join('/'), |
| 21 | dirname: (p: string) => p.split('/').slice(0, -1).join('/'), |
| 22 | resolve: (...parts: string[]) => parts.join('/'), |
| 23 | extname: (p: string) => p.slice(p.lastIndexOf('.')), |
| 24 | relative: (from: string, to: string) => to.replace(`${from}/`, ''), |
| 25 | isAbsolute: (p: string) => p.startsWith('/'), |
| 26 | sep: '/', |
| 27 | abs: (_cwd: string, p: string) => p, |
| 28 | }, |
| 29 | cwd: () => '/project', |
| 30 | env: () => undefined, |
| 31 | }, |
| 32 | hooks: {}, |
| 33 | } as any) |
| 34 | } |
| 35 | |
| 36 | describe('OutputEngine.write', () => { |
| 37 | test('writes when the file does not exist', async () => { |
no test coverage detected