11import postcss from "postcss" ;
2- import containerQuery , { getMetadataFromMessages } from "./containerQuery" ;
32import Root from "../__mocks__/Root" ;
43import * as regularTest from "./test/regular" ;
54import * as customPropertiesTest from "./test/custom-properties" ;
@@ -11,7 +10,11 @@ import * as missingDeclarationWithRUnitsTest from "./test/missing-declaration-wi
1110import * as selfTest from "./test/self" ;
1211import * as simpleTest from "./test/simple" ;
1312
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" ) ;
1518
1619/**
1720 * @param {string } rawCSS Raw CSS containing container queries
@@ -53,14 +56,22 @@ const assertProcessingResult = async (testObj, options = {}) => {
5356 expect ( meta ) . toEqual ( testObj . meta ) ;
5457} ;
5558
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+ } ) ;
5867
68+ test ( "should use the default json saving function if none was supplied" , ( ) => {
69+ const fs = require ( "fs" ) ;
5970 const pluginInstance = containerQuery ( ) ;
6071
6172 pluginInstance ( new Root ( ) , { messages : [ ] } ) ;
6273
63- expect ( saveMeta ) . toHaveBeenCalledTimes ( 1 ) ;
74+ expect ( fs . readFile ) . toHaveBeenCalledTimes ( 1 ) ;
6475} ) ;
6576
6677test ( "should throw on missing container declaration" , ( ) => {
0 commit comments