mirror of https://github.com/Squidex/squidex.git
Browse Source
* Fix for value changes * References # Conflicts: # frontend/app/features/content/shared/forms/array-item.component.ts * More fixes for value changes.pull/489/head
committed by
GitHub
16 changed files with 139 additions and 59 deletions
@ -0,0 +1,46 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { FormControl, Validators } from '@angular/forms'; |
||||
|
|
||||
|
import { value$ } from './forms-helper'; |
||||
|
|
||||
|
describe('FormHelpers', () => { |
||||
|
describe('value$', () => { |
||||
|
it('should provide change values', () => { |
||||
|
const form = new FormControl('1', Validators.required); |
||||
|
|
||||
|
const values: any[] = []; |
||||
|
|
||||
|
value$(form).subscribe(x => { |
||||
|
values.push(x); |
||||
|
}); |
||||
|
|
||||
|
form.setValue('2'); |
||||
|
form.setValue('3'); |
||||
|
|
||||
|
expect(values).toEqual(['1', '2', '3']); |
||||
|
}); |
||||
|
|
||||
|
it('should not trigger on disable', () => { |
||||
|
const form = new FormControl('1', Validators.required); |
||||
|
|
||||
|
const values: any[] = []; |
||||
|
|
||||
|
value$(form).subscribe(x => { |
||||
|
values.push(x); |
||||
|
}); |
||||
|
|
||||
|
form.setValue('2'); |
||||
|
form.enable(); |
||||
|
form.setValue('3'); |
||||
|
form.disable(); |
||||
|
|
||||
|
expect(values).toEqual(['1', '2', '3']); |
||||
|
}); |
||||
|
}); |
||||
|
}); |
||||
Loading…
Reference in new issue