From 619b8ab8220a7bc87a512d597c19a063d0ca5fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 6 Dec 2017 22:30:00 +0800 Subject: [PATCH] test(forms): add test on applying unicode flag (#20819) PR Close #20819 --- packages/forms/test/validators_spec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/forms/test/validators_spec.ts b/packages/forms/test/validators_spec.ts index 148157e2ba..efcf6cc88a 100644 --- a/packages/forms/test/validators_spec.ts +++ b/packages/forms/test/validators_spec.ts @@ -11,6 +11,7 @@ import {describe, expect, it} from '@angular/core/testing/src/testing_internal'; import {AbstractControl, AsyncValidatorFn, FormArray, FormControl, Validators} from '@angular/forms'; import {normalizeAsyncValidator} from '@angular/forms/src/directives/normalize_validator'; import {AsyncValidator, ValidationErrors, ValidatorFn} from '@angular/forms/src/directives/validators'; +import {browserDetection} from '@angular/platform-browser/testing/src/browser_util'; import {Observable, of , timer} from 'rxjs'; import {first, map} from 'rxjs/operators'; @@ -274,6 +275,13 @@ import {first, map} from 'rxjs/operators'; it('should not error on "undefined" pattern', () => expect(Validators.pattern(undefined !)(new FormControl('aaAA'))).toBeNull()); + if (browserDetection.supportsRegExUnicodeFlag) { + it('should apply unicode flag to pattern when supported', () => { + expect(Validators.pattern('[\u{10000}-\u{10001}]')(new FormControl('\u{10000}'))) + .toBeNull(); + }); + } + it('should work with pattern string containing both boundary symbols', () => expect(Validators.pattern('^[aA]*$')(new FormControl('aaAA'))).toBeNull());