1
+ import { MEMFS_VOLUME } from '@ng-rspack/testing-utils' ;
2
+ import { vol } from 'memfs' ;
3
+ import { join } from 'node:path' ;
1
4
import { describe , expect } from 'vitest' ;
2
5
import {
3
6
DEFAULT_PLUGIN_ANGULAR_OPTIONS ,
6
9
normalizeOutputPath ,
7
10
resolveFileReplacements ,
8
11
} from './normalize-options.ts' ;
9
- import { vol } from 'memfs' ;
10
-
11
- import { MEMFS_VOLUME } from '@ng-rspack/testing-utils' ;
12
12
import { PluginAngularOptions } from './plugin-options' ;
13
13
14
14
describe ( 'resolveFileReplacements' , ( ) => {
@@ -60,58 +60,52 @@ describe('getHasServer', () => {
60
60
} ) ;
61
61
62
62
it ( 'should return true if both server and ssr.entry files exist' , ( ) => {
63
- const result = getHasServer ( {
64
- server : 'server.js' ,
65
- ssr : { entry : 'ssr-entry.js' } ,
63
+ const result = getHasServer ( process . cwd ( ) , 'server.js' , {
64
+ entry : 'ssr-entry.js' ,
66
65
} ) ;
67
66
68
67
expect ( result ) . toBe ( true ) ;
69
68
} ) ;
70
69
71
70
it ( 'should return false if server file is not provides' , ( ) => {
72
- const result = getHasServer ( {
73
- ssr : { entry : 'ssr-entry.js' } ,
71
+ const result = getHasServer ( process . cwd ( ) , undefined , {
72
+ entry : 'ssr-entry.js' ,
74
73
} ) ;
75
74
76
75
expect ( result ) . toBe ( false ) ;
77
76
} ) ;
78
77
79
78
it ( 'should return false if ssr.entry file is not provides' , ( ) => {
80
- const result = getHasServer ( {
81
- server : 'server.js' ,
82
- } ) ;
79
+ const result = getHasServer ( process . cwd ( ) , 'server.js' , undefined ) ;
83
80
84
81
expect ( result ) . toBe ( false ) ;
85
82
} ) ;
86
83
87
84
it ( 'should return false if neither file are not provides' , ( ) => {
88
- const result = getHasServer ( { } ) ;
85
+ const result = getHasServer ( process . cwd ( ) , undefined , undefined ) ;
89
86
90
87
expect ( result ) . toBe ( false ) ;
91
88
} ) ;
92
89
93
90
it ( 'should return false if server file does not exist' , ( ) => {
94
- const result = getHasServer ( {
95
- server : 'non-existing-server.js' ,
96
- ssr : { entry : 'ssr-entry.js' } ,
91
+ const result = getHasServer ( process . cwd ( ) , 'non-existing-server.js' , {
92
+ entry : 'ssr-entry.js' ,
97
93
} ) ;
98
94
99
95
expect ( result ) . toBe ( false ) ;
100
96
} ) ;
101
97
102
98
it ( 'should return false if ssr.entry file does not exist' , ( ) => {
103
- const result = getHasServer ( {
104
- server : 'server.js' ,
105
- ssr : { entry : 'non-existing-ssr-entry.js' } ,
99
+ const result = getHasServer ( process . cwd ( ) , 'server.js' , {
100
+ entry : 'non-existing-ssr-entry.js' ,
106
101
} ) ;
107
102
108
103
expect ( result ) . toBe ( false ) ;
109
104
} ) ;
110
105
111
106
it ( 'should return false if neither server nor ssr.entry exists' , ( ) => {
112
- const result = getHasServer ( {
113
- server : 'non-existing-server.js' ,
114
- ssr : { entry : 'non-existing-ssr-entry.js' } ,
107
+ const result = getHasServer ( process . cwd ( ) , 'non-existing-server.js' , {
108
+ entry : 'non-existing-ssr-entry.js' ,
115
109
} ) ;
116
110
117
111
expect ( result ) . toBe ( false ) ;
@@ -140,6 +134,8 @@ describe('normalizeOptions', () => {
140
134
141
135
expect ( result ) . toStrictEqual ( {
142
136
...defaultOptions ,
137
+ root : process . cwd ( ) ,
138
+ tsConfig : join ( process . cwd ( ) , 'tsconfig.app.json' ) ,
143
139
advancedOptimizations : true ,
144
140
} ) ;
145
141
} ) ;
@@ -149,6 +145,8 @@ describe('normalizeOptions', () => {
149
145
150
146
expect ( result ) . toStrictEqual ( {
151
147
...defaultOptions ,
148
+ root : process . cwd ( ) ,
149
+ tsConfig : join ( process . cwd ( ) , 'tsconfig.app.json' ) ,
152
150
advancedOptimizations : true ,
153
151
} ) ;
154
152
} ) ;
@@ -158,6 +156,8 @@ describe('normalizeOptions', () => {
158
156
159
157
expect ( result ) . toStrictEqual ( {
160
158
...defaultOptions ,
159
+ root : process . cwd ( ) ,
160
+ tsConfig : join ( process . cwd ( ) , 'tsconfig.app.json' ) ,
161
161
optimization : false ,
162
162
advancedOptimizations : false ,
163
163
} ) ;
0 commit comments