mirror of https://github.com/abpframework/abp.git
2 changed files with 90 additions and 0 deletions
@ -0,0 +1,44 @@ |
|||||
|
import { createHostFactory, SpectatorHost } from '@ngneat/spectator/jest'; |
||||
|
import { FormCheckboxComponent } from '../components/checkbox/checkbox.component'; |
||||
|
|
||||
|
describe('FormCheckboxComponent', () => { |
||||
|
let spectator: SpectatorHost<FormCheckboxComponent>; |
||||
|
|
||||
|
const createHost = createHostFactory(FormCheckboxComponent); |
||||
|
|
||||
|
beforeEach( |
||||
|
() => |
||||
|
(spectator = createHost( |
||||
|
'<abp-checkbox></abp-checkbox>', |
||||
|
{ |
||||
|
hostProps: { attributes: { autofocus: '', name: 'abp-checkbox' } }, |
||||
|
}, |
||||
|
)), |
||||
|
); |
||||
|
|
||||
|
it('should display the input', () => { |
||||
|
expect(spectator.query('input')).toBeTruthy(); |
||||
|
}); |
||||
|
|
||||
|
it('should equal the default classes to form-check-input', () => { |
||||
|
expect(spectator.query('input')).toHaveClass('form-check-input'); |
||||
|
}); |
||||
|
|
||||
|
it('should equal the default type to checkbox', () => { |
||||
|
expect(spectator.query('input')).toHaveAttribute('type', 'checkbox'); |
||||
|
}); |
||||
|
|
||||
|
it('should be readonly when checkboxReadonly is true', () => { |
||||
|
spectator.component.checkboxReadonly = true; |
||||
|
spectator.detectComponentChanges(); |
||||
|
expect(spectator.query('[readonly]')).toBeTruthy(); |
||||
|
}); |
||||
|
|
||||
|
it('should not contain readonly when checboxReadonly is false', () => { |
||||
|
spectator.component.checkboxReadonly = false; |
||||
|
spectator.detectComponentChanges(); |
||||
|
expect(spectator.query('[disabled]')).toBeFalsy(); |
||||
|
}); |
||||
|
|
||||
|
}); |
||||
|
|
||||
@ -0,0 +1,46 @@ |
|||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
import { createHostFactory, SpectatorHost } from '@ngneat/spectator/jest'; |
||||
|
import { FormInputComponent } from '../components/form-input/form-input.component'; |
||||
|
|
||||
|
|
||||
|
describe('FormInputComponent', () => { |
||||
|
let spectator: SpectatorHost<FormInputComponent>; |
||||
|
|
||||
|
const createHost = createHostFactory(FormInputComponent); |
||||
|
|
||||
|
beforeEach( |
||||
|
() => |
||||
|
(spectator = createHost( |
||||
|
'<abp-form-input></abp-form-input>', |
||||
|
{ |
||||
|
hostProps: { attributes: { autofocus: '', name: 'abp-form-input' } }, |
||||
|
}, |
||||
|
)), |
||||
|
); |
||||
|
|
||||
|
it('should display the input', () => { |
||||
|
expect(spectator.query('input')).toBeTruthy(); |
||||
|
}); |
||||
|
|
||||
|
it('should equal the default classes to form-control', () => { |
||||
|
expect(spectator.query('input')).toHaveClass('form-control'); |
||||
|
}); |
||||
|
|
||||
|
it('should equal the default type to text', () => { |
||||
|
expect(spectator.query('input')).toHaveAttribute('type', 'text'); |
||||
|
}); |
||||
|
|
||||
|
it('should be readonly when inputReadonly is true', () => { |
||||
|
spectator.component.inputReadonly = true; |
||||
|
spectator.detectComponentChanges(); |
||||
|
expect(spectator.query('[readonly]')).toBeTruthy(); |
||||
|
}); |
||||
|
|
||||
|
it('should not contain readonly when inputReadonly is false', () => { |
||||
|
spectator.component.inputReadonly = false; |
||||
|
spectator.detectComponentChanges(); |
||||
|
expect(spectator.query('[disabled]')).toBeFalsy(); |
||||
|
}); |
||||
|
|
||||
|
}); |
||||
|
|
||||
Loading…
Reference in new issue