@@ -545,7 +545,7 @@ title = 'igniteui-angular example';
545545 }
546546 } ) ) ;
547547 expect ( fsSpy . writeFile ) . toHaveBeenCalledTimes ( 1 ) ;
548- expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 5 ) ;
548+ expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 6 ) ;
549549 } ) ;
550550
551551 it ( "Should update import paths in files correctly" , async ( ) => {
@@ -713,7 +713,7 @@ export default function Home() {
713713 for ( const fileEntry of mockFileArray ) {
714714 expect ( ( fsSpy . writeFile as jasmine . Spy ) ) . toHaveBeenCalledWith ( fileEntry . path , fileEntry . expected ) ;
715715 }
716- expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 5 ) ;
716+ expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 6 ) ;
717717 } ) ;
718718
719719 it ( "Should update package.json files from workspaces with glob patterns" , async ( ) => {
@@ -842,7 +842,94 @@ export default function Home() {
842842 for ( const fileEntry of mockFileArray ) {
843843 expect ( ( fsSpy . writeFile as jasmine . Spy ) ) . toHaveBeenCalledWith ( fileEntry . path , fileEntry . expected ) ;
844844 }
845- // Expect: 1 for projects/*, 1 for package.json files at root, 1 for logic files, 1 for style files, 1 for package.json in workspace
845+ // Expect: 1 for projects/*, 1 for package.json files at root, 1 for logic files, 1 for style files, 1 for package.json in workspace, 1 for vite.config.ts
846+ expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 7 ) ;
847+ } ) ;
848+
849+ it ( "Should update vite.config.ts file correctly" , async ( ) => {
850+ const mockFileArray : MockFile [ ] = [
851+ {
852+ path : "package.json" ,
853+ content :
854+ `{
855+ "dependencies": {
856+ "igniteui-react-grids": "^18.5.1",
857+ "some-package": "^0.0.0"
858+ }
859+ }
860+ ` ,
861+ expected :
862+ `{
863+ "dependencies": {
864+ "@infragistics/igniteui-react-grids": "^18.5.1",
865+ "some-package": "^0.0.0"
866+ }
867+ }
868+ `
869+ } ,
870+ {
871+ path : "vite.config.ts" ,
872+ content :
873+ `import { defineConfig } from 'vite';
874+ import { viteStaticCopy } from 'vite-plugin-static-copy';
875+
876+ export default defineConfig({
877+ plugins: [
878+ viteStaticCopy({
879+ targets: [
880+ {
881+ src: "node_modules/igniteui-react-grids/grids/themes/light/bootstrap.css",
882+ dest: "themes",
883+ },
884+ {
885+ src: "node_modules/igniteui-react-grids/grids/themes/light/fluent.css",
886+ dest: "themes",
887+ },
888+ ],
889+ }),
890+ ],
891+ });` ,
892+ expected :
893+ `import { defineConfig } from 'vite';
894+ import { viteStaticCopy } from 'vite-plugin-static-copy';
895+
896+ export default defineConfig({
897+ plugins: [
898+ viteStaticCopy({
899+ targets: [
900+ {
901+ src: "node_modules/@infragistics/igniteui-react-grids/grids/themes/light/bootstrap.css",
902+ dest: "themes",
903+ },
904+ {
905+ src: "node_modules/@infragistics/igniteui-react-grids/grids/themes/light/fluent.css",
906+ dest: "themes",
907+ },
908+ ],
909+ }),
910+ ],
911+ });`
912+ } ] ;
913+ ( fsSpy . glob as jasmine . Spy ) . and . returnValues // per workspace
914+ ( [ "package.json" ] , // root package.json
915+ [ ] , // html file
916+ [ "src/home.tsx" ] , // logic files
917+ [ ] , // for each style extension
918+ [ ] , // inner package.json files
919+ [ "vite.config.ts" ] ) ; // vite config files
920+ ( fsSpy . readFile as jasmine . Spy ) . and . callFake ( ( filePath : string ) => {
921+ if ( filePath . indexOf ( "package.json" ) > - 1 ) {
922+ return mockFileArray . find ( entry => entry . path === "package.json" ) . content ;
923+ }
924+ const fileEntry = mockFileArray . find ( entry => entry . path === filePath ) ;
925+ return fileEntry ? fileEntry . content : "" ;
926+ } ) ;
927+ ( fsSpy . fileExists as jasmine . Spy ) . and . returnValue ( true ) ;
928+ spyOn ( PackageManager , "ensureRegistryUser" ) . and . returnValue ( true ) ;
929+ expect ( await updateWorkspace ( "" ) ) . toEqual ( true ) ;
930+ for ( const fileEntry of mockFileArray ) {
931+ expect ( ( fsSpy . writeFile as jasmine . Spy ) ) . toHaveBeenCalledWith ( fileEntry . path , fileEntry . expected ) ;
932+ }
846933 expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 6 ) ;
847934 } ) ;
848935 } ) ;
@@ -931,7 +1018,7 @@ export default function Home() {
9311018 }
9321019 } ) ) ;
9331020 expect ( fsSpy . writeFile ) . toHaveBeenCalledTimes ( 2 ) ;
934- expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 4 ) ;
1021+ expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 5 ) ;
9351022 } ) ;
9361023
9371024 it ( "Should update import paths in files correctly" , async ( ) => {
@@ -1086,7 +1173,7 @@ export default class App extends LitElement {
10861173 for ( const fileEntry of mockFileArray ) {
10871174 expect ( ( fsSpy . writeFile as jasmine . Spy ) ) . toHaveBeenCalledWith ( fileEntry . path , fileEntry . expected ) ;
10881175 }
1089- expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 4 ) ;
1176+ expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 5 ) ;
10901177 } ) ;
10911178
10921179 it ( "Should update package.json files from workspaces" , async ( ) => {
@@ -1201,7 +1288,97 @@ export default class App extends LitElement {
12011288 for ( const fileEntry of mockFileArray ) {
12021289 expect ( ( fsSpy . writeFile as jasmine . Spy ) ) . toHaveBeenCalledWith ( fileEntry . path , fileEntry . expected ) ;
12031290 }
1204- expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 6 ) ;
1291+ expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 7 ) ;
1292+ } ) ;
1293+
1294+ it ( "Should update vite.config.ts file correctly" , async ( ) => {
1295+ const mockFileArray : MockFile [ ] = [
1296+ {
1297+ path : "package.json" ,
1298+ content :
1299+ `{
1300+ "dependencies": {
1301+ "igniteui-webcomponents-grids": "^4.7.0",
1302+ "some-package": "^0.0.0"
1303+ }
1304+ }
1305+ ` ,
1306+ expected :
1307+ `{
1308+ "dependencies": {
1309+ "@infragistics/igniteui-webcomponents-grids": "^4.7.0",
1310+ "some-package": "^0.0.0"
1311+ }
1312+ }
1313+ `
1314+ } ,
1315+ {
1316+ path : "vite.config.ts" ,
1317+ content :
1318+ `import { defineConfig } from 'vite';
1319+ import { viteStaticCopy } from 'vite-plugin-static-copy';
1320+
1321+ export default defineConfig(({ mode }) => {
1322+ return {
1323+ plugins: [
1324+ viteStaticCopy({
1325+ targets: [
1326+ {
1327+ src: "node_modules/igniteui-webcomponents-grids/grids/themes/light/bootstrap.css",
1328+ dest: "themes",
1329+ },
1330+ {
1331+ src: "node_modules/igniteui-webcomponents-grids/grids/themes/light/fluent.css",
1332+ dest: "themes",
1333+ },
1334+ ],
1335+ }),
1336+ ],
1337+ };
1338+ });` ,
1339+ expected :
1340+ `import { defineConfig } from 'vite';
1341+ import { viteStaticCopy } from 'vite-plugin-static-copy';
1342+
1343+ export default defineConfig(({ mode }) => {
1344+ return {
1345+ plugins: [
1346+ viteStaticCopy({
1347+ targets: [
1348+ {
1349+ src: "node_modules/@infragistics/igniteui-webcomponents-grids/grids/themes/light/bootstrap.css",
1350+ dest: "themes",
1351+ },
1352+ {
1353+ src: "node_modules/@infragistics/igniteui-webcomponents-grids/grids/themes/light/fluent.css",
1354+ dest: "themes",
1355+ },
1356+ ],
1357+ }),
1358+ ],
1359+ };
1360+ });`
1361+ } ] ;
1362+ ( fsSpy . glob as jasmine . Spy ) . and . returnValues // per workspace
1363+ ( [ "package.json" ] , // root package.json
1364+ [ ] , // html file
1365+ [ "src/app.ts" ] , // logic files
1366+ [ ] , // inner package.json files
1367+ [ "vite.config.ts" ] ) ; // vite config files
1368+ ( fsSpy . readFile as jasmine . Spy ) . and . callFake ( ( filePath : string ) => {
1369+ if ( filePath . indexOf ( "package.json" ) > - 1 ) {
1370+ return mockFileArray . find ( entry => entry . path === "package.json" ) . content ;
1371+ }
1372+ const fileEntry = mockFileArray . find ( entry => entry . path === filePath ) ;
1373+ return fileEntry ? fileEntry . content : "" ;
1374+ } ) ;
1375+ ( fsSpy . fileExists as jasmine . Spy ) . and . returnValue ( true ) ;
1376+ spyOn ( PackageManager , "ensureRegistryUser" ) . and . returnValue ( true ) ;
1377+ expect ( await updateWorkspace ( "" ) ) . toEqual ( true ) ;
1378+ for ( const fileEntry of mockFileArray ) {
1379+ expect ( ( fsSpy . writeFile as jasmine . Spy ) ) . toHaveBeenCalledWith ( fileEntry . path , fileEntry . expected ) ;
1380+ }
1381+ expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 5 ) ;
12051382 } ) ;
12061383 } ) ;
12071384} ) ;
0 commit comments