|
16 | 16 | import { join } from 'node:path'; |
17 | 17 | import { assert, expect } from 'chai'; |
18 | 18 | import { Messages, SfError } from '@salesforce/core'; |
19 | | -import { ForceIgnore, RegistryAccess, SourceComponent, VirtualTreeContainer, registry } from '../../../src'; |
| 19 | +import { ForceIgnore, RegistryAccess, SourceComponent, VirtualDirectory, VirtualTreeContainer, registry } from '../../../src'; |
20 | 20 | import { WebApplicationsSourceAdapter } from '../../../src/resolve/adapters'; |
21 | 21 | import { RegistryTestUtil } from '../registryTestUtil'; |
22 | 22 |
|
@@ -152,4 +152,54 @@ describe('WebApplicationsSourceAdapter', () => { |
152 | 152 | ); |
153 | 153 | testUtil.restore(); |
154 | 154 | }); |
| 155 | + |
| 156 | + describe('app name case', () => { |
| 157 | + const buildAdapterWithAppName = (appName: string) => { |
| 158 | + const appPath = join(BASE_PATH, appName); |
| 159 | + const metaFile = join(appPath, `${appName}.webapplication-meta.xml`); |
| 160 | + const config = { outputDir: 'src', routing: { trailingSlash: 'auto', fallback: '/index.html' } }; |
| 161 | + const vfs: VirtualDirectory[] = [ |
| 162 | + { |
| 163 | + dirPath: appPath, |
| 164 | + children: [ |
| 165 | + `${appName}.webapplication-meta.xml`, |
| 166 | + { name: 'webapplication.json', data: Buffer.from(JSON.stringify(config)) }, |
| 167 | + 'src', |
| 168 | + ], |
| 169 | + }, |
| 170 | + { dirPath: join(appPath, 'src'), children: ['index.html'] }, |
| 171 | + ]; |
| 172 | + const t = new VirtualTreeContainer(vfs); |
| 173 | + return { |
| 174 | + adapter: new WebApplicationsSourceAdapter(registry.types.webapplication, registryAccess, forceIgnore, t), |
| 175 | + appPath, |
| 176 | + metaFile, |
| 177 | + }; |
| 178 | + }; |
| 179 | + |
| 180 | + it('should preserve mixed-case app name (MyApp)', () => { |
| 181 | + const { adapter, appPath, metaFile } = buildAdapterWithAppName('MyApp'); |
| 182 | + const comp = adapter.getComponent(appPath); |
| 183 | + expect(comp).to.not.be.undefined; |
| 184 | + expect(comp!.name).to.equal('MyApp'); |
| 185 | + expect(comp!.fullName).to.equal('MyApp'); |
| 186 | + expect(comp!.xml).to.equal(metaFile); |
| 187 | + }); |
| 188 | + |
| 189 | + it('should preserve lowercase app name (myapp)', () => { |
| 190 | + const { adapter, appPath } = buildAdapterWithAppName('myapp'); |
| 191 | + const comp = adapter.getComponent(appPath); |
| 192 | + expect(comp).to.not.be.undefined; |
| 193 | + expect(comp!.name).to.equal('myapp'); |
| 194 | + expect(comp!.fullName).to.equal('myapp'); |
| 195 | + }); |
| 196 | + |
| 197 | + it('should preserve uppercase app name (MYAPP)', () => { |
| 198 | + const { adapter, appPath } = buildAdapterWithAppName('MYAPP'); |
| 199 | + const comp = adapter.getComponent(appPath); |
| 200 | + expect(comp).to.not.be.undefined; |
| 201 | + expect(comp!.name).to.equal('MYAPP'); |
| 202 | + expect(comp!.fullName).to.equal('MYAPP'); |
| 203 | + }); |
| 204 | + }); |
155 | 205 | }); |
0 commit comments