|
6 | 6 | * found in the LICENSE file at https://angular.dev/license |
7 | 7 | */ |
8 | 8 |
|
9 | | -import {computed, effect, Injector, signal} from '@angular/core'; |
| 9 | +import {computed, effect, Injector, signal, WritableSignal} from '@angular/core'; |
10 | 10 | import {TestBed} from '@angular/core/testing'; |
11 | 11 | import { |
12 | 12 | apply, |
@@ -121,6 +121,41 @@ describe('FieldNode', () => { |
121 | 121 | f().reset(); |
122 | 122 | expect(f.a().value()).toBe(1); |
123 | 123 | }); |
| 124 | + |
| 125 | + it('can reset with empty string', () => { |
| 126 | + const model = signal('hello'); |
| 127 | + const f = form(model, {injector: TestBed.inject(Injector)}); |
| 128 | + f().reset(''); |
| 129 | + expect(f().value()).toBe(''); |
| 130 | + }); |
| 131 | + |
| 132 | + it('can reset with false', () => { |
| 133 | + const model = signal(true); |
| 134 | + const f = form(model, {injector: TestBed.inject(Injector)}); |
| 135 | + f().reset(false); |
| 136 | + expect(f().value()).toBe(false); |
| 137 | + }); |
| 138 | + |
| 139 | + it('can reset with null', () => { |
| 140 | + const model: WritableSignal<string | null> = signal('hello'); |
| 141 | + const f = form(model, {injector: TestBed.inject(Injector)}); |
| 142 | + f().reset(null); |
| 143 | + expect(f().value()).toBeNull(); |
| 144 | + }); |
| 145 | + |
| 146 | + it('can reset with 0', () => { |
| 147 | + const model = signal(5); |
| 148 | + const f = form(model, {injector: TestBed.inject(Injector)}); |
| 149 | + f().reset(0); |
| 150 | + expect(f().value()).toBe(0); |
| 151 | + }); |
| 152 | + |
| 153 | + it('can reset with NaN', () => { |
| 154 | + const model = signal(5); |
| 155 | + const f = form(model, {injector: TestBed.inject(Injector)}); |
| 156 | + f().reset(NaN); |
| 157 | + expect(f().value()).toBeNaN(); |
| 158 | + }); |
124 | 159 | }); |
125 | 160 |
|
126 | 161 | describe('dirty', () => { |
|
0 commit comments