11import templates from "@/templates" ;
2+ import { Kebab , Pascal } from "@/utils/formats" ;
23import { template } from "@/utils/tags" ;
34import {
45 factoryTemplateMock ,
@@ -15,9 +16,9 @@ describe("Code generation", () => {
1516
1617 it ( "should generate a repository template" , ( ) => {
1718 const expected : Component = {
18- filename : template `${ { value : resource , casing : "kebab" } } .repository.ts` ,
19+ filename : template `${ new Kebab ( resource ) } .repository.ts` ( ) ,
1920 body : repositoryTemplateMock ,
20- name : template `${ { value : resource , casing : "pascal" } } Repository` ,
21+ name : template `${ new Pascal ( resource ) } Repository` ( ) ,
2122 } ;
2223
2324 const result = templates . get ( "repository" ) ?.( resource ) ;
@@ -28,53 +29,41 @@ describe("Code generation", () => {
2829
2930 it ( "should generate a service template" , ( ) => {
3031 const expected : Component = {
31- filename : template `${ { value : resource , casing : "kebab" } } .service.ts` ,
32+ filename : template `${ new Kebab ( resource ) } .service.ts` ( ) ,
3233 body : serviceTemplateMock ,
33- name : template `${ { value : resource , casing : "pascal" } } Service` ,
34+ name : template `${ new Pascal ( resource ) } Service` ( ) ,
3435 } ;
3536
3637 const result = templates . get ( "service" ) ?.( resource ) ;
3738
3839 expect ( result ) . toEqual ( expected ) ;
3940 expect ( result ?. body ) . toContain (
40- template `import ${ {
41- value : resource ,
42- casing : "pascal" ,
43- } } Repository from "../repository/${ {
44- value : resource ,
45- casing : "kebab" ,
46- } } .repository";`,
41+ template `import ${ new Pascal (
42+ resource ,
43+ ) } Repository from "../repository/${ new Kebab ( resource ) } .repository";`( ) ,
4744 ) ;
4845 expect ( result ?. body ) . toContain ( `export default class ${ result ?. name } ` ) ;
4946 } ) ;
5047
5148 it ( "should generate a factory template" , ( ) => {
5249 const expected : Component = {
53- filename : template `${ { value : resource , casing : "kebab" } } .factory.ts` ,
50+ filename : template `${ new Kebab ( resource ) } .factory.ts` ( ) ,
5451 body : factoryTemplateMock ,
55- name : template `${ { value : resource , casing : "pascal" } } Factory` ,
52+ name : template `${ new Pascal ( resource ) } Factory` ( ) ,
5653 } ;
5754
5855 const result = templates . get ( "factory" ) ?.( resource ) ;
5956
6057 expect ( result ) . toEqual ( expected ) ;
6158 expect ( result ?. body ) . toContain (
62- template `import ${ {
63- value : resource ,
64- casing : "pascal" ,
65- } } Repository from "../repository/${ {
66- value : resource ,
67- casing : "kebab" ,
68- } } .repository";`,
59+ template `import ${ new Pascal (
60+ resource ,
61+ ) } Repository from "../repository/${ new Kebab ( resource ) } .repository";`( ) ,
6962 ) ;
7063 expect ( result ?. body ) . toContain (
71- template `import ${ {
72- value : resource ,
73- casing : "pascal" ,
74- } } Service from "../service/${ {
75- value : resource ,
76- casing : "kebab" ,
77- } } .service";`,
64+ template `import ${ new Pascal (
65+ resource ,
66+ ) } Service from "../service/${ new Kebab ( resource ) } .service";`( ) ,
7867 ) ;
7968 expect ( result ?. body ) . toContain ( `export default class ${ result ?. name } ` ) ;
8069 } ) ;
0 commit comments