1
- const path = require ( "path" ) ;
2
- const { expect } = require ( "chai" ) ;
3
- const loadConfig = require ( "../../../src/config-utl/extract-depcruise-config" ) ;
4
- const fixture = require ( "./__mocks__/rules.sub-not-allowed-error.json" ) ;
5
- const mergedFixture = require ( "./__mocks__/extends/merged.json" ) ;
6
- const mergedArrayOneFixture = require ( "./__mocks__/extends/merged-array-1.json" ) ;
7
- const mergedArrayTwoFixture = require ( "./__mocks__/extends/merged-array-2.json" ) ;
1
+ import { fileURLToPath } from "node:url" ;
2
+ import path from "node:path" ;
3
+ import { expect } from "chai" ;
4
+ import loadConfig from "../../../src/config-utl/extract-depcruise-config/index.js" ;
8
5
6
+ const __dirname = fileURLToPath ( new URL ( "." , import . meta. url ) ) ;
9
7
const mockDirectory = path . join ( __dirname , "__mocks__" ) ;
10
8
11
9
describe ( "[I] config-utl/compile-config" , ( ) => {
12
- it ( "a rule set without an extends returns just that rule set" , ( ) => {
10
+ it ( "a rule set without an extends returns just that rule set" , async ( ) => {
11
+ const fixture = await import (
12
+ "./__mocks__/rules.sub-not-allowed-error.json" ,
13
+ {
14
+ assert : { type : "json" } ,
15
+ }
16
+ ) ;
13
17
expect (
14
18
loadConfig ( path . join ( mockDirectory , "rules.sub-not-allowed-error.json" ) )
15
- ) . to . deep . equal ( fixture ) ;
19
+ ) . to . deep . equal ( fixture . default ) ;
16
20
} ) ;
17
21
18
- it ( "a rule set with an extends returns that rule set, extending the mentioned base" , ( ) => {
22
+ it ( "a rule set with an extends returns that rule set, extending the mentioned base" , async ( ) => {
23
+ const mergedFixture = await import ( "./__mocks__/extends/merged.json" , {
24
+ assert : { type : "json" } ,
25
+ } ) ;
19
26
expect (
20
27
loadConfig ( path . join ( mockDirectory , "extends/extending.json" ) )
21
- ) . to . deep . equal ( mergedFixture ) ;
28
+ ) . to . deep . equal ( mergedFixture . default ) ;
22
29
} ) ;
23
30
24
31
it ( "a rule set with an extends array (0 members) returns that rule set" , ( ) => {
@@ -40,23 +47,35 @@ describe("[I] config-utl/compile-config", () => {
40
47
} ) ;
41
48
} ) ;
42
49
43
- it ( "a rule set with an extends array (1 member) returns that rule set, extending the mentioned base" , ( ) => {
50
+ it ( "a rule set with an extends array (1 member) returns that rule set, extending the mentioned base" , async ( ) => {
51
+ const mergedArrayOneFixture = await import (
52
+ "./__mocks__/extends/merged-array-1.json" ,
53
+ {
54
+ assert : { type : "json" } ,
55
+ }
56
+ ) ;
44
57
expect (
45
58
loadConfig (
46
59
path . join ( mockDirectory , "extends/extending-array-with-one-member.json" )
47
60
)
48
- ) . to . deep . equal ( mergedArrayOneFixture ) ;
61
+ ) . to . deep . equal ( mergedArrayOneFixture . default ) ;
49
62
} ) ;
50
63
51
- it ( "a rule set with an extends array (>1 member) returns that rule set, extending the mentioned bases" , ( ) => {
64
+ it ( "a rule set with an extends array (>1 member) returns that rule set, extending the mentioned bases" , async ( ) => {
65
+ const mergedArrayTwoFixture = await import (
66
+ "./__mocks__/extends/merged-array-2.json" ,
67
+ {
68
+ assert : { type : "json" } ,
69
+ }
70
+ ) ;
52
71
expect (
53
72
loadConfig (
54
73
path . join (
55
74
mockDirectory ,
56
75
"extends/extending-array-with-two-members.json"
57
76
)
58
77
)
59
- ) . to . deep . equal ( mergedArrayTwoFixture ) ;
78
+ ) . to . deep . equal ( mergedArrayTwoFixture . default ) ;
60
79
} ) ;
61
80
62
81
it ( "a rule set with an extends from node_modules gets merged properly as well" , ( ) => {
0 commit comments