|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google Inc. All Rights Reserved. |
| 4 | + * |
| 5 | + * Use of this source code is governed by an MIT-style license that can be |
| 6 | + * found in the LICENSE file at https://angular.io/license |
| 7 | + */ |
| 8 | +import { Architect } from '@angular-devkit/architect'; |
| 9 | +import { logging } from '@angular-devkit/core'; |
| 10 | +import { createArchitect, host } from '../../test-utils'; |
| 11 | + |
| 12 | +describe('Browser Builder browser support', () => { |
| 13 | + const targetSpec = { project: 'app', target: 'build' }; |
| 14 | + let architect: Architect; |
| 15 | + |
| 16 | + beforeEach(async () => { |
| 17 | + await host.initialize().toPromise(); |
| 18 | + architect = (await createArchitect(host.root())).architect; |
| 19 | + |
| 20 | + // target ES5 to disable differential loading which is not needed for the tests |
| 21 | + host.replaceInFile('tsconfig.json', '"target": "es2015"', '"target": "es5"'); |
| 22 | + }); |
| 23 | + afterEach(async () => host.restore().toPromise()); |
| 24 | + |
| 25 | + it('warns when IE9 is present in browserslist', async () => { |
| 26 | + host.appendToFile('.browserslistrc', '\nIE 9'); |
| 27 | + |
| 28 | + const logger = new logging.Logger(''); |
| 29 | + const logs: string[] = []; |
| 30 | + logger.subscribe((e) => logs.push(e.message)); |
| 31 | + |
| 32 | + const run = await architect.scheduleTarget(targetSpec, undefined, { logger }); |
| 33 | + const output = await run.result; |
| 34 | + expect(output.success).toBe(true); |
| 35 | + |
| 36 | + const fullLog = logs.join(); |
| 37 | + expect(fullLog).toContain( |
| 38 | + "WARNING: Support was requested for IE 9 in the project's browserslist configuration.", |
| 39 | + ); |
| 40 | + expect(fullLog).toContain('This browser is '); |
| 41 | + |
| 42 | + await run.stop(); |
| 43 | + }); |
| 44 | + |
| 45 | + it('warns when IE10 is present in browserslist', async () => { |
| 46 | + host.appendToFile('.browserslistrc', '\nIE 10'); |
| 47 | + |
| 48 | + const logger = new logging.Logger(''); |
| 49 | + const logs: string[] = []; |
| 50 | + logger.subscribe((e) => logs.push(e.message)); |
| 51 | + |
| 52 | + const run = await architect.scheduleTarget(targetSpec, undefined, { logger }); |
| 53 | + const output = await run.result; |
| 54 | + expect(output.success).toBe(true); |
| 55 | + |
| 56 | + const fullLog = logs.join(); |
| 57 | + expect(fullLog).toContain( |
| 58 | + "WARNING: Support was requested for IE 10 in the project's browserslist configuration.", |
| 59 | + ); |
| 60 | + expect(fullLog).toContain('This browser is '); |
| 61 | + |
| 62 | + await run.stop(); |
| 63 | + }); |
| 64 | + |
| 65 | + it('warns when both IE9 & IE10 are present in browserslist', async () => { |
| 66 | + host.appendToFile('.browserslistrc', '\nIE 9-10'); |
| 67 | + |
| 68 | + const logger = new logging.Logger(''); |
| 69 | + const logs: string[] = []; |
| 70 | + logger.subscribe((e) => logs.push(e.message)); |
| 71 | + |
| 72 | + const run = await architect.scheduleTarget(targetSpec, undefined, { logger }); |
| 73 | + const output = await run.result; |
| 74 | + expect(output.success).toBe(true); |
| 75 | + |
| 76 | + const fullLog = logs.join(); |
| 77 | + expect(fullLog).toContain( |
| 78 | + "WARNING: Support was requested for IE 9 & IE 10 in the project's browserslist configuration.", |
| 79 | + ); |
| 80 | + expect(fullLog).toContain('These browsers are '); |
| 81 | + |
| 82 | + await run.stop(); |
| 83 | + }); |
| 84 | +}); |
0 commit comments