|
1 | 1 | import { JsonObject, logging } from '@angular-devkit/core'; |
2 | | -import { BuilderContext, BuilderRun, ScheduleOptions, Target } from '@angular-devkit/architect/src/index'; |
| 2 | +import { BuilderContext, BuilderOutput, BuilderRun, ScheduleOptions, Target } from '@angular-devkit/architect/src/index'; |
3 | 3 | import deploy from './actions'; |
4 | 4 |
|
5 | 5 | let context: BuilderContext; |
@@ -53,6 +53,18 @@ describe('Deploy Angular apps', () => { |
53 | 53 | expect(e.message).toMatch(/Cannot execute the build target/); |
54 | 54 | } |
55 | 55 | }); |
| 56 | + |
| 57 | + it('throws if app building fails', async () => { |
| 58 | + context.scheduleTarget = (_: Target, __?: JsonObject, ___?: ScheduleOptions) => Promise.resolve({ |
| 59 | + result: Promise.resolve(createBuilderOutputMock(false, 'build error test')), |
| 60 | + } as BuilderRun); |
| 61 | + try { |
| 62 | + await deploy(mockEngine, context, 'host', {}); |
| 63 | + fail(); |
| 64 | + } catch (e) { |
| 65 | + expect(e.message).toMatch(/build error test/); |
| 66 | + } |
| 67 | + }); |
56 | 68 | }); |
57 | 69 | }); |
58 | 70 |
|
@@ -81,6 +93,17 @@ const initMocks = () => { |
81 | 93 | reportStatus: (_: string) => { }, |
82 | 94 | reportRunning: () => { }, |
83 | 95 | scheduleBuilder: (_: string, __?: JsonObject, ___?: ScheduleOptions) => Promise.resolve({} as BuilderRun), |
84 | | - scheduleTarget: (_: Target, __?: JsonObject, ___?: ScheduleOptions) => Promise.resolve({} as BuilderRun) |
| 96 | + scheduleTarget: (_: Target, __?: JsonObject, ___?: ScheduleOptions) => Promise.resolve({ |
| 97 | + result: Promise.resolve(createBuilderOutputMock(true, '')), |
| 98 | + } as BuilderRun) |
| 99 | + }; |
| 100 | +}; |
| 101 | + |
| 102 | +const createBuilderOutputMock = (success: boolean, error: string): BuilderOutput => { |
| 103 | + return { |
| 104 | + info: { 'info': null }, |
| 105 | + error: error, |
| 106 | + success: success, |
| 107 | + target: {} as Target, |
85 | 108 | }; |
86 | 109 | }; |
0 commit comments