8
8
import { json , schema } from '@angular-devkit/core' ;
9
9
import { timer } from 'rxjs' ;
10
10
import { map , take , tap , toArray } from 'rxjs/operators' ;
11
+ import { promisify } from 'util' ;
11
12
import { TestingArchitectHost } from '../testing/testing-architect-host' ;
12
13
import { BuilderOutput , BuilderRun } from './api' ;
13
14
import { Architect } from './architect' ;
14
15
import { createBuilder } from './create-builder' ;
15
16
17
+ const flush = promisify ( setImmediate ) ;
18
+
16
19
// tslint:disable-next-line:no-big-function
17
20
describe ( 'architect' , ( ) => {
18
21
let testArchitectHost : TestingArchitectHost ;
@@ -81,6 +84,7 @@ describe('architect', () => {
81
84
it ( 'runs builders parallel' , async ( ) => {
82
85
const run = await architect . scheduleBuilder ( 'package:test' , { } ) ;
83
86
const run2 = await architect . scheduleBuilder ( 'package:test' , { } ) ;
87
+ await flush ( ) ;
84
88
expect ( called ) . toBe ( 2 ) ;
85
89
expect ( await run . result ) . toEqual ( jasmine . objectContaining ( { success : true } ) ) ;
86
90
expect ( await run2 . result ) . toEqual ( jasmine . objectContaining ( { success : true } ) ) ;
@@ -91,6 +95,7 @@ describe('architect', () => {
91
95
it ( 'runs targets parallel' , async ( ) => {
92
96
const run = await architect . scheduleTarget ( target1 , { } ) ;
93
97
const run2 = await architect . scheduleTarget ( target1 , { } ) ;
98
+ await flush ( ) ;
94
99
expect ( called ) . toBe ( 2 ) ;
95
100
expect ( await run . result ) . toEqual ( jasmine . objectContaining ( { success : true } ) ) ;
96
101
expect ( await run2 . result ) . toEqual ( jasmine . objectContaining ( { success : true } ) ) ;
@@ -164,6 +169,7 @@ describe('architect', () => {
164
169
called ++ ;
165
170
166
171
for ( let x = 0 ; x < 10 ; x ++ ) {
172
+ await new Promise ( setImmediate ) ;
167
173
context . reportRunning ( ) ;
168
174
yield { success : true } ;
169
175
results ++ ;
0 commit comments