@@ -21,6 +21,15 @@ export function renderMapContains(renderMap: RenderMap, key: string, expected: (
2121 return codeContains ( renderMap . get ( key ) , expected ) ;
2222}
2323
24+ export function renderMapDoesNotContain (
25+ renderMap : RenderMap ,
26+ key : string ,
27+ expected : ( RegExp | string ) [ ] | RegExp | string ,
28+ ) {
29+ expect ( renderMap . has ( key ) , `RenderMap is missing key "${ key } ".` ) . toBe ( true ) ;
30+ return codeDoesNotContain ( renderMap . get ( key ) , expected ) ;
31+ }
32+
2433export async function codeContains ( actual : string , expected : ( RegExp | string ) [ ] | RegExp | string ) {
2534 const expectedArray = Array . isArray ( expected ) ? expected : [ expected ] ;
2635 const normalizedActual = await normalizeCode ( actual ) ;
@@ -50,6 +59,15 @@ export function renderMapContainsImports(renderMap: RenderMap, key: string, expe
5059 return codeContainsImports ( renderMap . get ( key ) , expectedImports ) ;
5160}
5261
62+ export function renderMapDoesNotContainImports (
63+ renderMap : RenderMap ,
64+ key : string ,
65+ expectedImports : Record < string , string [ ] > ,
66+ ) {
67+ expect ( renderMap . has ( key ) , `RenderMap is missing key "${ key } ".` ) . toBe ( true ) ;
68+ return codeDoesNotContainImports ( renderMap . get ( key ) , expectedImports ) ;
69+ }
70+
5371export async function codeContainsImports ( actual : string , expectedImports : Record < string , string [ ] > ) {
5472 const normalizedActual = await inlineCode ( actual ) ;
5573 const importPairs = Object . entries ( expectedImports ) . flatMap ( ( [ key , value ] ) => {
@@ -61,6 +79,17 @@ export async function codeContainsImports(actual: string, expectedImports: Recor
6179 } ) ;
6280}
6381
82+ export async function codeDoesNotContainImports ( actual : string , expectedImports : Record < string , string [ ] > ) {
83+ const normalizedActual = await inlineCode ( actual ) ;
84+ const importPairs = Object . entries ( expectedImports ) . flatMap ( ( [ key , value ] ) => {
85+ return value . map ( v => [ key , v ] as const ) ;
86+ } ) ;
87+
88+ importPairs . forEach ( ( [ importFrom , importValue ] ) => {
89+ expect ( normalizedActual ) . not . toMatch ( new RegExp ( `import{[^}]*\\b${ importValue } \\b[^}]*}from'${ importFrom } '` ) ) ;
90+ } ) ;
91+ }
92+
6493export function codeStringAsRegex ( code : string ) {
6594 const stringAsRegex = escapeRegex ( code )
6695 // Transform spaces between words into required whitespace.
0 commit comments