aboutsummaryrefslogtreecommitdiffstats
path: root/src/angular/form-elements/radios/radio-buttons-group.component.spec.ts
blob: 273a701c8e12586d8be3618be7c842c0ca756f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { TestBed, async } from '@angular/core/testing';
import { RadioGroupComponent } from "./radio-buttons-group.component";
import { FormsModule } from "@angular/forms";
import { IRadioButtonModel } from "./radio-button.model";
import { AnimationDirectivesModule } from "../../animations/animation-directives.module";


describe("Radio Buttons unit-tests", ()=>{
    let component: RadioGroupComponent;
    beforeEach(async(() => {
        TestBed.configureTestingModule({
            declarations: [
                RadioGroupComponent
            ],
            imports:[
                FormsModule,
                AnimationDirectivesModule
            ]
        }).compileComponents();

        const fixture = TestBed.createComponent(RadioGroupComponent);
        component = fixture.componentInstance;
        component.disabled = false;//TODO constructor
        component.options = {
            items: []
        };
    }));

    it('Component Created', async(()=> {
        expect(component).toBeDefined();
    }));

    it('Not possible to choose value which not exists', async(() =>{
        component.value = 'test';
        expect(component.value).not.toEqual('test');
    }));

    it('Normal flow', async(() =>{
        component.options.items = [ <IRadioButtonModel> {
            value: 'val1',
            name: 'exp6',
            label: 'Label of Radio1'
        }, <IRadioButtonModel> {
            value: 'val2',
            name: 'exp6',
            label: 'Label of Radio2'
        }];
        component.value = component.options.items[0].value;
        expect(component.value).toEqual(component.options.items[0].value);
    }));

});