@@ -3,39 +3,39 @@ import { existsSync } from "node:fs";
33import { createFixture } from "./fixture.ts" ;
44
55describe ( "createFixture" , ( ) => {
6- it ( "creates files on disk from inline tree" , async ( ) => {
7- const fixture = await createFixture ( {
8- "hello.txt" : "hello world" ,
9- } ) ;
10- expect ( await fixture . text ( "hello.txt" ) ) . toBe ( "hello world" ) ;
11- } ) ;
6+ it ( "creates files on disk from inline tree" , async ( ) => {
7+ const fixture = await createFixture ( {
8+ "hello.txt" : "hello world" ,
9+ } ) ;
10+ expect ( await fixture . text ( "hello.txt" ) ) . toBe ( "hello world" ) ;
11+ } ) ;
1212
13- it ( "creates nested directories from slash-separated keys" , async ( ) => {
14- const fixture = await createFixture ( {
15- "src/index.ts" : "export const x = 1" ,
16- "src/utils/helpers.ts" : "export function help() {}" ,
17- } ) ;
18- expect ( await fixture . isFile ( "src/index.ts" ) ) . toBe ( true ) ;
19- expect ( await fixture . isFile ( "src/utils/helpers.ts" ) ) . toBe ( true ) ;
20- } ) ;
13+ it ( "creates nested directories from slash-separated keys" , async ( ) => {
14+ const fixture = await createFixture ( {
15+ "src/index.ts" : "export const x = 1" ,
16+ "src/utils/helpers.ts" : "export function help() {}" ,
17+ } ) ;
18+ expect ( await fixture . isFile ( "src/index.ts" ) ) . toBe ( true ) ;
19+ expect ( await fixture . isFile ( "src/utils/helpers.ts" ) ) . toBe ( true ) ;
20+ } ) ;
2121
22- it ( "resolve returns absolute path within fixture root" , async ( ) => {
23- const fixture = await createFixture ( { "a.txt" : "" } ) ;
24- expect ( fixture . resolve ( "a.txt" ) . toString ( ) ) . toContain ( fixture . root . toString ( ) ) ;
25- } ) ;
22+ it ( "resolve returns absolute path within fixture root" , async ( ) => {
23+ const fixture = await createFixture ( { "a.txt" : "" } ) ;
24+ expect ( fixture . resolve ( "a.txt" ) . toString ( ) ) . toContain ( fixture . root . toString ( ) ) ;
25+ } ) ;
2626
27- it ( "text reads the actual file" , async ( ) => {
28- const fixture = await createFixture ( { "a.txt" : "Empty" } ) ;
29- expect ( await fixture . text ( "a.txt" ) ) . toEqual ( "Empty" ) ;
30- await fixture . write ( "a.txt" , "Hello world!" ) ;
31- expect ( await fixture . text ( "a.txt" ) ) . toEqual ( "Hello world!" ) ;
32- } ) ;
27+ it ( "text reads the actual file" , async ( ) => {
28+ const fixture = await createFixture ( { "a.txt" : "Empty" } ) ;
29+ expect ( await fixture . text ( "a.txt" ) ) . toEqual ( "Empty" ) ;
30+ await fixture . write ( "a.txt" , "Hello world!" ) ;
31+ expect ( await fixture . text ( "a.txt" ) ) . toEqual ( "Hello world!" ) ;
32+ } ) ;
3333
34- it ( "cleanup removes the temp directory" , async ( ) => {
35- const fixture = await createFixture ( { "a.txt" : "" } ) ;
36- const path = fixture . root ;
37- expect ( await fixture . isDirectory ( fixture . root ) ) . toBe ( true ) ;
38- await fixture . cleanup ( ) ;
39- expect ( existsSync ( path ) ) . toBe ( false ) ;
40- } ) ;
34+ it ( "cleanup removes the temp directory" , async ( ) => {
35+ const fixture = await createFixture ( { "a.txt" : "" } ) ;
36+ const path = fixture . root ;
37+ expect ( await fixture . isDirectory ( fixture . root ) ) . toBe ( true ) ;
38+ await fixture . cleanup ( ) ;
39+ expect ( existsSync ( path ) ) . toBe ( false ) ;
40+ } ) ;
4141} ) ;
0 commit comments