Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Chain.op((v) => {
// Should be dirty after user input but remain untouched
fakeKeyUp(v.editorComponent.editor, 'X');
v.fixture.detectChanges();
Assertions.assertEq('ngModel should not be pristine', false, v.ngModel.pristine);
Assertions.assertEq('ngModel should not be touched', false, v.ngModel.touched);
// If the editor loses focus, it should should remain dirty but should also turn touched
v.editorComponent.editor.fire('blur');
v.fixture.detectChanges();
Assertions.assertEq('ngModel should not be pristine', false, v.ngModel.pristine);
Assertions.assertEq('ngModel should be touched', true, v.ngModel.touched);
}),
cTeardown
Chain.op((v) => {
// Should be dirty after user input but remain untouched
fakeKeyUp(v.editorComponent.editor, 'X');
v.fixture.detectChanges();
Assertions.assertEq('ngModel should not be pristine', false, v.ngModel.pristine);
Assertions.assertEq('ngModel should not be touched', false, v.ngModel.touched);
// If the editor loses focus, it should should remain dirty but should also turn touched
v.editorComponent.editor.fire('blur');
v.fixture.detectChanges();
Assertions.assertEq('ngModel should not be pristine', false, v.ngModel.pristine);
Assertions.assertEq('ngModel should be touched', true, v.ngModel.touched);
}),
cTeardown
Chain.op((v) => {
Assertions.assertEq('ngModel should be valid', true, v.ngModel.valid);
Assertions.assertEq('ngModel should be pristine', true, v.ngModel.pristine);
Assertions.assertEq('ngModel should not be touched', false, v.ngModel.touched);
}),
cTeardown
Chain.op((v) => {
v.editorComponent.writeValue('New Value');
v.fixture.detectChanges();
Assertions.assertEq('ngModel should be valid', true, v.ngModel.valid);
Assertions.assertEq('ngModel should be pristine', true, v.ngModel.pristine);
Assertions.assertEq('ngModel should not be touched', false, v.ngModel.touched);
Assertions.assertEq(
'Value should have been written to the editor',
v.editorComponent.editor.getContent({ format: 'text' }),
'New Value'
);
}),
cTeardown
Chain.op((v) => {
v.editorComponent.writeValue('New Value');
v.fixture.detectChanges();
Assertions.assertEq('ngModel should be valid', true, v.ngModel.valid);
Assertions.assertEq('ngModel should be pristine', true, v.ngModel.pristine);
Assertions.assertEq('ngModel should not be touched', false, v.ngModel.touched);
Assertions.assertEq(
'Value should have been written to the editor',
v.editorComponent.editor.getContent({ format: 'text' }),
'New Value'
);
}),
cTeardown
Chain.op((v) => {
Assertions.assertEq('ngModel should be valid', true, v.ngModel.valid);
Assertions.assertEq('ngModel should be pristine', true, v.ngModel.pristine);
Assertions.assertEq('ngModel should not be touched', false, v.ngModel.touched);
}),
cTeardown