-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdropdown.component.spec.ts
More file actions
109 lines (91 loc) · 2.88 KB
/
Copy pathdropdown.component.spec.ts
File metadata and controls
109 lines (91 loc) · 2.88 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { DropdownComponent } from './dropdown.component';
describe('DropdownComponent', () => {
let component: DropdownComponent;
let fixture: ComponentFixture<DropdownComponent>;
let fakeInfo: any;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ DropdownComponent ]
})
.compileComponents();
fakeInfo = {
id: 'fake',
name: 'fake',
description: 'fake',
tenant_id: '',
status: '',
key: 'active',
_status: false,
btnColor: 'btn-white',
btnIcon: 'fa-circle',
btnIconTwo: 'fa-caret-check',
btnName: 'Active',
iconColor: 'text-success'
};
fixture = TestBed.createComponent(DropdownComponent);
component = fixture.componentInstance;
}));
it('should create', () => {
expect(component).toBeTruthy();
});
it('should emit the item when clicked in method changeOperation', () => {
spyOn(component.updateInfo, 'emit');
component.info = fakeInfo;
fixture.detectChanges();
component.changeOperation(fakeInfo);
expect(component.updateInfo.emit).toHaveBeenCalled();
});
it('should changed properties of item when is Active', () => {
const fakeInfoActive = {
id: 'fake',
name: 'fake',
description: 'fake',
tenant_id: '',
status: '',
key: 'active',
_status: true,
btnColor: 'btn-white',
btnIcon: 'fa-circle',
btnIconTwo: 'fa-caret-check',
btnName: 'Active',
iconColor: 'text-success'
};
const expectChangeValue = {
btnName: 'Inactive',
btnIcon: 'fa-circle',
iconColor: 'text-danger'
};
component.info = fakeInfoActive;
component.changePropertiesItem(fakeInfoActive);
expect(component.dataChange.btnName).toEqual(expectChangeValue.btnName);
expect(component.dataChange.btnIcon).toEqual(expectChangeValue.btnIcon);
expect(component.dataChange.iconColor).toEqual(expectChangeValue.iconColor);
});
it('should change properties of item when is Inactive', () => {
const fakeInfoInactive = {
id: 'fake',
name: 'fake',
description: 'fake',
tenant_id: '',
status: '',
key: 'active',
_status: true,
btnColor: 'btn-white',
btnIcon: 'fa-circle',
btnIconTwo: 'fa-caret-check',
btnName: 'Inactive',
iconColor: 'text-danger'
};
const expectChangeValue = {
btnName: 'Active',
btnIcon: 'fa-circle',
iconColor: 'text-success'
};
component.info = fakeInfoInactive;
component.changePropertiesItem(fakeInfoInactive);
expect(component.dataChange.btnName).toEqual(expectChangeValue.btnName);
expect(component.dataChange.btnIcon).toEqual(expectChangeValue.btnIcon);
expect(component.dataChange.iconColor).toEqual(expectChangeValue.iconColor);
});
});