From dd92519f8d831f257408fdcf09e35742b725dfd7 Mon Sep 17 00:00:00 2001 From: Kevin Merckx Date: Fri, 11 May 2018 12:01:35 +0200 Subject: [PATCH] test(checkbox): add missing test for checkbox global container class config --- .../checkbox/checkbox.component.spec.ts | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/app/ui/checkbox/checkbox/checkbox.component.spec.ts b/src/app/ui/checkbox/checkbox/checkbox.component.spec.ts index 78d23b5..1d1d89f 100644 --- a/src/app/ui/checkbox/checkbox/checkbox.component.spec.ts +++ b/src/app/ui/checkbox/checkbox/checkbox.component.spec.ts @@ -1,6 +1,8 @@ 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; @@ -8,7 +10,12 @@ describe('CheckboxComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ CheckboxComponent ] + declarations: [ CheckboxComponent ], + providers: [{ + provide: IW_CHECKBOX_CONFIG, useValue: { + containerClass: 'checkbox-test-class' + } + }] }) .compileComponents(); })); @@ -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: { + 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(); + }); +});