@@ -2,29 +2,28 @@ import * as core from '@form8ion/core';
22import * as readme from '@form8ion/readme' ;
33import * as gitPlugin from '@form8ion/git' ;
44
5- import { afterEach , describe , expect , it , vi } from 'vitest' ;
5+ import { beforeEach , describe , expect , it , vi } from 'vitest' ;
66import any from '@travi/any' ;
77import { when } from 'vitest-when' ;
88
9+ import { scaffold as scaffoldEditorconfig , test as editorconfigInUse } from './editorconfig/index.js' ;
910import * as licensePlugin from './license/index.js' ;
1011import lift from './lift.js' ;
1112
1213vi . mock ( 'deepmerge' ) ;
1314vi . mock ( '@form8ion/core' ) ;
1415vi . mock ( '@form8ion/readme' ) ;
16+ vi . mock ( './editorconfig/index.js' ) ;
1517
1618describe ( 'lift' , ( ) => {
17- afterEach ( ( ) => {
18- vi . clearAllMocks ( ) ;
19- } ) ;
19+ const projectRoot = any . string ( ) ;
20+ const results = any . simpleObject ( ) ;
21+ const enhancers = any . simpleObject ( ) ;
22+ const vcs = any . simpleObject ( ) ;
23+ const dependencies = any . simpleObject ( ) ;
24+ const enhancerResults = any . simpleObject ( ) ;
2025
21- it ( 'should lift the README based on the provided results' , async ( ) => {
22- const projectRoot = any . string ( ) ;
23- const enhancers = any . simpleObject ( ) ;
24- const dependencies = any . simpleObject ( ) ;
25- const vcs = any . simpleObject ( ) ;
26- const results = any . simpleObject ( ) ;
27- const enhancerResults = any . simpleObject ( ) ;
26+ beforeEach ( ( ) => {
2827 when ( core . applyEnhancers )
2928 . calledWith ( {
3029 results,
@@ -33,8 +32,21 @@ describe('lift', () => {
3332 dependencies
3433 } )
3534 . thenResolve ( enhancerResults ) ;
35+ } ) ;
36+
37+ it ( 'should lift the README based on the provided results' , async ( ) => {
38+ when ( editorconfigInUse ) . calledWith ( { projectRoot} ) . thenResolve ( true ) ;
3639
3740 expect ( await lift ( { projectRoot, results, enhancers, vcs, dependencies} ) ) . toEqual ( enhancerResults ) ;
3841 expect ( readme . lift ) . toHaveBeenCalledWith ( { projectRoot, results : enhancerResults } ) ;
42+ expect ( scaffoldEditorconfig ) . not . toHaveBeenCalled ( ) ;
43+ } ) ;
44+
45+ it ( 'should scaffold editorconfig when it isnt already in use' , async ( ) => {
46+ when ( editorconfigInUse ) . calledWith ( { projectRoot} ) . thenResolve ( false ) ;
47+
48+ await lift ( { projectRoot, results, enhancers, vcs, dependencies} ) ;
49+
50+ expect ( scaffoldEditorconfig ) . toHaveBeenCalledWith ( { projectRoot} ) ;
3951 } ) ;
4052} ) ;
0 commit comments