Skip to content

Commit

Permalink
Added more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi committed Apr 17, 2018
1 parent 1d2f331 commit 6a69d89
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/app/duration-picker/duration-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ describe('DurationPickerComponent', () => {
let component: DurationPickerComponent;
let fixture: ComponentFixture<DurationPickerComponent>;

const myFunc = () => 'something';

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DurationPickerComponent ],
Expand Down Expand Up @@ -120,6 +122,46 @@ describe('DurationPickerComponent', () => {
expect(component.minutes).toBe(0);
expect(component.seconds).toBe(0);
});

it('setDisabledState() should correctly change the disabled status', () => {
component.setDisabledState(true);
expect(component.disabled).toBe(true);

component.setDisabledState(false);
expect(component.disabled).toBe(false);
});

it('registerOnChange(fn) should correctly set the onChange function', () => {
component.onChange = null;

component.registerOnChange(myFunc);

expect(component.onChange).toEqual(myFunc);
});

it('registerOnTouched(fn) should correctly set the onTouched function', () => {
component.onTouched = null;

component.registerOnTouched(myFunc);

expect(component.onTouched).toEqual(myFunc);
});

it('writeValue(value) should change the value when the new value is NOT null', () => {
component.value = 'old value';

component.writeValue('new value');

expect(component.value).toEqual('new value');
});

it('writeValue(value) should NOT change the value if the new value is null', () => {
component.value = 'old value';

component.writeValue(null);

expect(component.value).toEqual('old value');
});
});

function set(
Expand Down

0 comments on commit 6a69d89

Please sign in to comment.