@@ -500,6 +500,7 @@ describe('Transform: rewriteModule', () => {
500500 }"
501501 ` ) ;
502502 } ) ;
503+
503504 test ( 'embedded gts templates' , ( ) => {
504505 let customEnv = GlintEnvironment . load ( [ 'ember-loose' , 'ember-template-imports' ] ) ;
505506 let script = {
@@ -890,31 +891,79 @@ describe('Transform: rewriteModule', () => {
890891 ` ) ;
891892 } ) ;
892893
893- test ( 'with implicit export default and satisfies' , ( ) => {
894- let customEnv = GlintEnvironment . load ( [ 'ember-loose' , 'ember-template-imports' ] ) ;
895- let script = {
896- filename : 'test.gts' ,
897- contents : stripIndent `
894+ describe ( 'satisfies' , ( ) => {
895+ test ( 'with implicit export default' , ( ) => {
896+ let customEnv = GlintEnvironment . load ( [ 'ember-loose' , 'ember-template-imports' ] ) ;
897+ let script = {
898+ filename : 'test.gts' ,
899+ contents : stripIndent `
900+ import type { TOC } from '@ember/component/template-only';
901+ <template>HelloWorld!</template> satisfies TOC<{
902+ Blocks: { default: [] }
903+ }>;
904+ ` ,
905+ } ;
906+
907+ let transformedModule = rewriteModule ( ts , { script } , customEnv ) ;
908+
909+ expect ( transformedModule ?. errors ) . toEqual ( [ ] ) ;
910+ expect ( transformedModule ?. transformedContents ) . toMatchInlineSnapshot ( `
911+ "import __GLINT_GTS_EXTENSION_HACK__ from './__glint-non-existent.gts';
912+ import __GLINT_GJS_EXTENSION_HACK__ from './__glint-non-existent.gjs';
898913 import type { TOC } from '@ember/component/template-only';
899- <template>HelloWorld!</template> satisfies TOC<{
914+ export default ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {
915+ __glintRef__; __glintDSL__;
916+ }) satisfies TOC<{
900917 Blocks: { default: [] }
901- }>;
902- ` ,
903- } ;
904-
905- let transformedModule = rewriteModule ( ts , { script } , customEnv ) ;
918+ }>;"
919+ ` ) ;
920+ } ) ;
921+
922+ test ( 'with two template-only components' , ( ) => {
923+ const emberTemplateImportsEnvironment = GlintEnvironment . load ( [ 'ember-template-imports' ] ) ;
924+
925+ let script = {
926+ filename : 'test.gts' ,
927+ contents : [
928+ `import type { TOC } from '@ember/component/template-only';` ,
929+ `` ,
930+ `const SmolComp = ` ,
931+ ` <template>` ,
932+ ` Hello there, {{@name}}` ,
933+ ` </template> satisfies TOC<{ Args: { name: string }}>;` ,
934+ `` ,
935+ `<template>` ,
936+ ` <SmolComp @name="Ember" />` ,
937+ `</template> satisfies TOC<{ Args: {}, Blocks: {}, Element: null }>` ,
938+ `` ,
939+ ] . join ( '\n' ) ,
940+ } ;
941+
942+ let transformedModule = rewriteModule ( ts , { script } , emberTemplateImportsEnvironment ) ;
943+
944+ expect ( transformedModule ?. errors ?. length ) . toBe ( 0 ) ;
945+ expect ( transformedModule ?. transformedContents ) . toMatchInlineSnapshot ( `
946+ "import __GLINT_GTS_EXTENSION_HACK__ from './__glint-non-existent.gts';
947+ import __GLINT_GJS_EXTENSION_HACK__ from './__glint-non-existent.gjs';
948+ import type { TOC } from '@ember/component/template-only';
906949
907- expect ( transformedModule ?. errors ) . toEqual ( [ ] ) ;
908- expect ( transformedModule ?. transformedContents ) . toMatchInlineSnapshot ( `
909- "import __GLINT_GTS_EXTENSION_HACK__ from './__glint-non-existent.gts';
910- import __GLINT_GJS_EXTENSION_HACK__ from './__glint-non-existent.gjs';
911- import type { TOC } from '@ember/component/template-only';
912- export default ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {
913- __glintRef__; __glintDSL__;
914- }) satisfies TOC<{
915- Blocks: { default: [] }
916- }>;"
917- ` ) ;
950+ const SmolComp =
951+ ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {
952+ __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.name)());
953+ __glintRef__; __glintDSL__;
954+ }) satisfies TOC<{ Args: { name: string }}>;
955+
956+ export default ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {
957+ {
958+ const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(SmolComp)({
959+ name: "Ember", ...__glintDSL__.NamedArgsMarker }));
960+ __glintY__;
961+ }
962+ __glintRef__; __glintDSL__;
963+ }) satisfies TOC<{ Args: {}, Blocks: {}, Element: null }>
964+ "
965+ ` ) ;
966+ } ) ;
918967 } ) ;
919968 } ) ;
920969} ) ;
0 commit comments