@@ -142,6 +142,61 @@ describe('MetadataResolver', () => {
142
142
expect ( access . getComponentsFromPath ( path ) ) . to . deep . equal ( [ matchingContentFile . COMPONENT ] ) ;
143
143
} ) ;
144
144
145
+ it ( 'Should determine type for metadata file with known suffix and strictDirectoryName' , ( ) => {
146
+ // CustomSite is an example. The conditions are:
147
+ // 1. Type has "strictDirectoryName": true
148
+ // 2. Type strategy adapter is neither "mixedContent" nor "bundle"
149
+ // 3. Type doesn't have children
150
+ // 4. mdapi format file path (E_Bikes.site)
151
+ const path = join ( 'unpackaged' , 'sites' , 'E_Bikes.site' ) ;
152
+ const treeContainer = VirtualTreeContainer . fromFilePaths ( [ path ] ) ;
153
+ const mdResolver = new MetadataResolver ( undefined , treeContainer ) ;
154
+ const expectedComponent = new SourceComponent (
155
+ {
156
+ name : 'E_Bikes' ,
157
+ type : registry . types . customsite ,
158
+ xml : path ,
159
+ } ,
160
+ treeContainer
161
+ ) ;
162
+ expect ( mdResolver . getComponentsFromPath ( path ) ) . to . deep . equal ( [ expectedComponent ] ) ;
163
+ } ) ;
164
+
165
+ it ( 'Should determine type for source file with known suffix and strictDirectoryName' , ( ) => {
166
+ // CustomSite is an example. The conditions are:
167
+ // 1. Type has "strictDirectoryName": true
168
+ // 2. Type strategy adapter is neither "mixedContent" nor "bundle"
169
+ // 3. Type doesn't have children
170
+ // 4. source format file path (E_Bikes.site-meta.xml)
171
+ const path = join ( 'unpackaged' , 'sites' , 'E_Bikes.site-meta.xml' ) ;
172
+ const treeContainer = VirtualTreeContainer . fromFilePaths ( [ path ] ) ;
173
+ const mdResolver = new MetadataResolver ( undefined , treeContainer ) ;
174
+ const expectedComponent = new SourceComponent (
175
+ {
176
+ name : 'E_Bikes' ,
177
+ type : registry . types . customsite ,
178
+ xml : path ,
179
+ } ,
180
+ treeContainer
181
+ ) ;
182
+ expect ( mdResolver . getComponentsFromPath ( path ) ) . to . deep . equal ( [ expectedComponent ] ) ;
183
+ } ) ;
184
+
185
+ it ( 'Should determine type for EmailServicesFunction metadata file (mdapi format)' , ( ) => {
186
+ const path = join ( 'unpackaged' , 'emailservices' , 'MyEmailServices.xml' ) ;
187
+ const treeContainer = VirtualTreeContainer . fromFilePaths ( [ path ] ) ;
188
+ const mdResolver = new MetadataResolver ( undefined , treeContainer ) ;
189
+ const expectedComponent = new SourceComponent (
190
+ {
191
+ name : 'MyEmailServices' ,
192
+ type : registry . types . emailservicesfunction ,
193
+ xml : path ,
194
+ } ,
195
+ treeContainer
196
+ ) ;
197
+ expect ( mdResolver . getComponentsFromPath ( path ) ) . to . deep . equal ( [ expectedComponent ] ) ;
198
+ } ) ;
199
+
145
200
it ( 'Should determine type for path of mixed content type' , ( ) => {
146
201
const path = mixedContentDirectory . MIXED_CONTENT_DIRECTORY_SOURCE_PATHS [ 1 ] ;
147
202
const access = testUtil . createMetadataResolver ( [
0 commit comments