Skip to content

Commit

Permalink
test(checkbox): add missing test for checkbox global container class …
Browse files Browse the repository at this point in the history
…config
  • Loading branch information
kevinmerckx committed May 11, 2018
1 parent 80fe57d commit dd92519
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/app/ui/checkbox/checkbox/checkbox.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { CheckboxComponent } from './checkbox.component';
import { IW_CHECKBOX_CONFIG } from '../checkbox.config';
import { CheckboxConfig } from '../checkbox-config.interface';

describe('CheckboxComponent', () => {
let component: CheckboxComponent;
let fixture: ComponentFixture<CheckboxComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CheckboxComponent ]
declarations: [ CheckboxComponent ],
providers: [{
provide: IW_CHECKBOX_CONFIG, useValue: <CheckboxConfig> {
containerClass: 'checkbox-test-class'
}
}]
})
.compileComponents();
}));
Expand Down Expand Up @@ -84,3 +91,30 @@ describe('CheckboxComponent', () => {
expect((component as any).changeDetectorRef.detectChanges).toHaveBeenCalled();
});
});

describe('Checkbox component global config', () => {
it('adds the containerClass provided as global config', () => {
TestBed.configureTestingModule({
declarations: [ CheckboxComponent ],
providers: [{
provide: IW_CHECKBOX_CONFIG, useValue: <CheckboxConfig> {
containerClass: 'checkbox-test-class'
}
}]
})
.compileComponents();
const fixture = TestBed.createComponent(CheckboxComponent);
fixture.detectChanges();
expect(fixture.debugElement.classes['checkbox-test-class']).toBe(true);
});

it('does not add the containerClass provided as global config', () => {
TestBed.configureTestingModule({
declarations: [ CheckboxComponent ]
})
.compileComponents();
const fixture = TestBed.createComponent(CheckboxComponent);
fixture.detectChanges();
expect(fixture.debugElement.classes['checkbox-test-class']).toBeFalsy();
});
});

0 comments on commit dd92519

Please sign in to comment.