mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
test(forms): move timeout and autoTick helpers to shared testing utilities
Centralizes common test helpers under testing utilities and updates usages
This commit is contained in:
committed by
Andrew Kushnir
parent
0c6eb60c86
commit
19d0ceede3
@@ -39,8 +39,8 @@ import {
|
||||
} from '../index';
|
||||
import {selectValueAccessor} from '../src/directives/shared';
|
||||
import {composeValidators} from '../src/validators';
|
||||
|
||||
import {asyncValidator, timeout, useAutoTick} from './util';
|
||||
import {useAutoTick, timeout} from '@angular/private/testing';
|
||||
import {asyncValidator} from './util';
|
||||
|
||||
class DummyControlValueAccessor implements ControlValueAccessor {
|
||||
writtenValue: any;
|
||||
|
||||
@@ -17,7 +17,8 @@ import {
|
||||
import {Validators} from '../src/validators';
|
||||
import {of} from 'rxjs';
|
||||
|
||||
import {asyncValidator, timeout, useAutoTick} from './util';
|
||||
import {useAutoTick, timeout} from '@angular/private/testing';
|
||||
import {asyncValidator} from './util';
|
||||
|
||||
(function () {
|
||||
describe('FormArray', () => {
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
Validators,
|
||||
} from '../index';
|
||||
import {of} from 'rxjs';
|
||||
import {timeout, useAutoTick} from './util';
|
||||
import {useAutoTick, timeout} from '@angular/private/testing';
|
||||
|
||||
(function () {
|
||||
function syncValidator() {
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
import {AsyncValidatorFn, FormArray, FormControl, FormGroup, Validators} from '../index';
|
||||
|
||||
import {asyncValidator, asyncValidatorReturningObservable, timeout, useAutoTick} from './util';
|
||||
import {asyncValidator, asyncValidatorReturningObservable} from './util';
|
||||
import {useAutoTick, timeout} from '@angular/private/testing';
|
||||
|
||||
(function () {
|
||||
function otherAsyncValidator() {
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
Validators,
|
||||
ValueChangeEvent,
|
||||
} from '../index';
|
||||
import {useAutoTick, timeout} from '@angular/private/testing';
|
||||
|
||||
import {FormControlStatus, StatusChangeEvent} from '../src/model/abstract_model';
|
||||
import {
|
||||
@@ -24,8 +25,6 @@ import {
|
||||
asyncValidatorReturningObservable,
|
||||
currentStateOf,
|
||||
simpleAsyncValidator,
|
||||
timeout,
|
||||
useAutoTick,
|
||||
} from './util';
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -19,7 +19,13 @@ import {
|
||||
} from '@angular/core';
|
||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {By} from '@angular/platform-browser';
|
||||
import {dispatchEvent, isNode, sortedClassList} from '@angular/private/testing';
|
||||
import {
|
||||
dispatchEvent,
|
||||
isNode,
|
||||
sortedClassList,
|
||||
useAutoTick,
|
||||
timeout,
|
||||
} from '@angular/private/testing';
|
||||
import {expect} from '@angular/private/testing/matchers';
|
||||
import {merge, NEVER, Observable, of, Subject, Subscription, timer} from 'rxjs';
|
||||
import {map, tap} from 'rxjs/operators';
|
||||
@@ -60,7 +66,6 @@ import {
|
||||
} from '../src/model/abstract_model';
|
||||
|
||||
import {MyInput, MyInputForm} from './value_accessor_integration_spec';
|
||||
import {timeout, useAutoTick} from './util';
|
||||
|
||||
// Produces a new @Directive (with a given selector) that represents a validator class.
|
||||
function createValidatorClass(selector: string) {
|
||||
|
||||
@@ -26,11 +26,10 @@ import {
|
||||
Validator,
|
||||
} from '../index';
|
||||
import {By} from '@angular/platform-browser';
|
||||
import {dispatchEvent, sortedClassList} from '@angular/private/testing';
|
||||
import {dispatchEvent, useAutoTick, timeout, sortedClassList} from '@angular/private/testing';
|
||||
import {merge} from 'rxjs';
|
||||
|
||||
import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integration_spec';
|
||||
import {timeout, useAutoTick} from './util';
|
||||
|
||||
describe('template-driven forms integration tests', () => {
|
||||
useAutoTick();
|
||||
|
||||
@@ -91,19 +91,3 @@ export function asyncValidatorReturningObservable(c: AbstractControl): EventEmit
|
||||
});
|
||||
return e;
|
||||
}
|
||||
|
||||
export async function timeout(ms?: number): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms);
|
||||
});
|
||||
}
|
||||
|
||||
export function useAutoTick() {
|
||||
beforeEach(() => {
|
||||
jasmine.clock().install();
|
||||
jasmine.clock().autoTick();
|
||||
});
|
||||
afterEach(() => {
|
||||
jasmine.clock().uninstall();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
} from '../index';
|
||||
|
||||
import {normalizeValidators} from '../src/validators';
|
||||
import {timeout, useAutoTick} from './util';
|
||||
import {useAutoTick, timeout} from '@angular/private/testing';
|
||||
|
||||
(function () {
|
||||
function validator(key: string, error: any): ValidatorFn {
|
||||
|
||||
@@ -39,9 +39,8 @@ import {
|
||||
Validators,
|
||||
} from '../index';
|
||||
import {By, ɵDomRendererFactory2 as DomRendererFactory2} from '@angular/platform-browser';
|
||||
import {dispatchEvent, isNode} from '@angular/private/testing';
|
||||
import {dispatchEvent, useAutoTick, timeout, isNode} from '@angular/private/testing';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {timeout, useAutoTick} from './util';
|
||||
|
||||
describe('value accessors', () => {
|
||||
useAutoTick();
|
||||
|
||||
Reference in New Issue
Block a user