-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(schematics): disable output hashing in configurations (#169)
- Loading branch information
Showing
4 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
schematics/ng-add/add-scripts.spec.ts → schematics/ng-add/tests/add-scripts.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; | ||
import { join } from 'path'; | ||
|
||
const collectionPath = join(__dirname, '../../schematics.json'); | ||
|
||
const workspaceOptions = { | ||
name: 'workspace', | ||
newProjectRoot: 'projects', | ||
version: '9.0.0', | ||
}; | ||
|
||
describe('https://github.com/single-spa/single-spa-angular/issues/168', () => { | ||
let workspaceTree: UnitTestTree; | ||
const testRunner = new SchematicTestRunner('single-spa-angular', collectionPath); | ||
|
||
function generateApplication(name: string, project?: string) { | ||
return testRunner | ||
.runExternalSchematicAsync( | ||
'@schematics/angular', | ||
'application', | ||
{ | ||
name, | ||
project, | ||
}, | ||
workspaceTree, | ||
) | ||
.toPromise(); | ||
} | ||
|
||
beforeEach(async () => { | ||
workspaceTree = await testRunner | ||
.runExternalSchematicAsync('@schematics/angular', 'workspace', workspaceOptions) | ||
.toPromise(); | ||
}); | ||
|
||
test('should update all configurations and disable output hashing', async () => { | ||
// Arrange | ||
const appTree = await generateApplication('first-cool-app'); | ||
let buildTarget = JSON.parse(`${appTree.get('/angular.json')!.content}`); | ||
let configurations = buildTarget.projects['first-cool-app'].architect.build.configurations; | ||
// `production` is always present by default | ||
const production = configurations.production; | ||
// Let's just add more configurations for testing purposes. | ||
configurations['us-dev'] = { ...production }; | ||
configurations['eu-west-1'] = { ...production }; | ||
|
||
// Act | ||
appTree.overwrite('/angular.json', JSON.stringify(buildTarget)); | ||
|
||
await testRunner.runSchematicAsync('ng-add', undefined, appTree).toPromise(); | ||
|
||
buildTarget = JSON.parse(`${appTree.get('/angular.json')!.content}`); | ||
configurations = buildTarget.projects['first-cool-app'].architect.build.configurations; | ||
|
||
// Arrange | ||
expect(Object.keys(configurations).length).toBe(3); | ||
|
||
for (const configuration of configurations) { | ||
expect(configuration.outputHashing).toBe('none'); | ||
} | ||
}); | ||
|
||
test('should update all configurations in the provided "--project"', async () => { | ||
// Arrange | ||
await generateApplication('first-cool-app'); | ||
const appTree = await generateApplication('second-cool-app', 'second-cool-app'); | ||
let buildTarget = JSON.parse(`${appTree.get('/angular.json')!.content}`); | ||
let configurations = buildTarget.projects['second-cool-app'].architect.build.configurations; | ||
// `production` is always present by default | ||
const production = configurations.production; | ||
// Let's just add more configurations for testing purposes. | ||
configurations['us-dev'] = { ...production }; | ||
configurations['eu-west-1'] = { ...production }; | ||
|
||
// Act | ||
appTree.overwrite('/angular.json', JSON.stringify(buildTarget)); | ||
|
||
await testRunner | ||
.runSchematicAsync('ng-add', { project: 'second-cool-app' }, appTree) | ||
.toPromise(); | ||
|
||
buildTarget = JSON.parse(`${appTree.get('/angular.json')!.content}`); | ||
configurations = buildTarget.projects['second-cool-app'].architect.build.configurations; | ||
|
||
// Arrange | ||
expect(Object.keys(configurations).length).toBe(3); | ||
|
||
for (const configuration of configurations) { | ||
expect(configuration.outputHashing).toBe('none'); | ||
} | ||
}); | ||
}); |