1
1
import fs from 'node:fs/promises' ;
2
2
import path from 'node:path' ;
3
- import { describe , it , expect , afterEach , beforeEach , assert } from 'vitest' ;
3
+ import { describe , it , expect , afterEach , beforeEach , assert , vi } from 'vitest' ;
4
4
import { loadConfig } from './load-config' ;
5
5
import {
6
6
allChecks ,
@@ -19,6 +19,7 @@ import {
19
19
} from '../test/test-helpers' ;
20
20
import { thisNodeModuleRoot } from './installation-location' ;
21
21
import { URI } from 'vscode-uri' ;
22
+ import * as resolveModule from './resolve' ;
22
23
23
24
describe ( 'Unit: loadConfig' , ( ) => {
24
25
let tempDir : string ;
@@ -34,8 +35,31 @@ describe('Unit: loadConfig', () => {
34
35
it ( 'loads the recommended config by default' , async ( ) => {
35
36
const config = await loadConfig ( undefined , __dirname ) ;
36
37
expect ( config . checks ) . to . eql ( recommended ) ;
38
+ expect ( config . context ) . to . eql ( 'theme' ) ;
37
39
} ) ;
38
40
41
+ describe . each ( [ 'shopify.extension.toml' , 'shopify.app.toml' ] ) (
42
+ 'when the root contains a %s file' ,
43
+ ( fileName ) => {
44
+ beforeEach ( async ( ) => {
45
+ const filePath = path . join ( tempDir , fileName ) ;
46
+ await fs . writeFile ( filePath , '' , 'utf8' ) ;
47
+ } ) ;
48
+
49
+ it ( 'sets the context to app' , async ( ) => {
50
+ const config = await loadConfig ( undefined , tempDir ) ;
51
+ expect ( config . context ) . to . eql ( 'app' ) ;
52
+ } ) ;
53
+
54
+ it ( 'calls resolveConfig with theme-check:theme-app-extension' , async ( ) => {
55
+ const spy = vi . spyOn ( resolveModule , 'resolveConfig' ) ;
56
+ await loadConfig ( undefined , tempDir ) ;
57
+ expect ( spy ) . toHaveBeenCalledWith ( 'theme-check:theme-app-extension' , true ) ;
58
+ vi . restoreAllMocks ( ) ;
59
+ } ) ;
60
+ } ,
61
+ ) ;
62
+
39
63
it ( 'extends the recommended config by default' , async ( ) => {
40
64
const configPath = await createMockConfigFile ( tempDir , `ignore: ['src/**']` ) ;
41
65
const config = await loadConfig ( configPath , tempDir ) ;
0 commit comments