1
1
import postcss from "postcss" ;
2
- import containerQuery , { getMetadataFromMessages } from "./containerQuery" ;
3
2
import Root from "../__mocks__/Root" ;
4
3
import * as regularTest from "./test/regular" ;
5
4
import * as customPropertiesTest from "./test/custom-properties" ;
@@ -11,7 +10,11 @@ import * as missingDeclarationWithRUnitsTest from "./test/missing-declaration-wi
11
10
import * as selfTest from "./test/self" ;
12
11
import * as simpleTest from "./test/simple" ;
13
12
14
- jest . mock ( "./saveMeta" ) ;
13
+ const containerQuery = require ( "../dist" ) ;
14
+ const getMetadataFromMessages = require ( "../dist/getMetadataFromMessages" ) ;
15
+ const saveMeta = require ( "../dist/saveMeta" ) ;
16
+
17
+ jest . mock ( "fs" ) ;
15
18
16
19
/**
17
20
* @param {string } rawCSS Raw CSS containing container queries
@@ -53,14 +56,22 @@ const assertProcessingResult = async (testObj, options = {}) => {
53
56
expect ( meta ) . toEqual ( testObj . meta ) ;
54
57
} ;
55
58
56
- test ( "should use the default json saving function if none was supplied" , ( ) => {
57
- const saveMeta = require ( "./saveMeta" ) . default ;
59
+ test ( 'should avoid accidentally creating ".default" exports' , ( ) => {
60
+ expect ( typeof saveMeta ) . toBe ( "function" ) ;
61
+ expect ( typeof getMetadataFromMessages ) . toBe ( "function" ) ;
62
+ expect ( typeof containerQuery ) . toBe ( "function" ) ;
63
+ expect ( typeof saveMeta . default ) . toBe ( "undefined" ) ;
64
+ expect ( typeof getMetadataFromMessages . default ) . toBe ( "undefined" ) ;
65
+ expect ( typeof containerQuery . default ) . toBe ( "undefined" ) ;
66
+ } ) ;
58
67
68
+ test ( "should use the default json saving function if none was supplied" , ( ) => {
69
+ const fs = require ( "fs" ) ;
59
70
const pluginInstance = containerQuery ( ) ;
60
71
61
72
pluginInstance ( new Root ( ) , { messages : [ ] } ) ;
62
73
63
- expect ( saveMeta ) . toHaveBeenCalledTimes ( 1 ) ;
74
+ expect ( fs . readFile ) . toHaveBeenCalledTimes ( 1 ) ;
64
75
} ) ;
65
76
66
77
test ( "should throw on missing container declaration" , ( ) => {
0 commit comments