@@ -2,12 +2,13 @@ import { IgxActionStripComponent } from './action-strip.component';
2
2
import { Component , ViewChild , ElementRef , ViewContainerRef } from '@angular/core' ;
3
3
import { configureTestSuite } from '../test-utils/configure-suite' ;
4
4
import { IgxIconModule } from '../icon/public_api' ;
5
- import { TestBed , fakeAsync , waitForAsync } from '@angular/core/testing' ;
5
+ import { TestBed } from '@angular/core/testing' ;
6
6
import { By } from '@angular/platform-browser' ;
7
7
import { wait } from '../test-utils/ui-interactions.spec' ;
8
8
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
9
9
import { IgxToggleModule } from '../directives/toggle/toggle.directive' ;
10
10
import { IgxActionStripModule } from './action-strip.module' ;
11
+ import { IgxDropDownModule } from '../drop-down/public_api' ;
11
12
12
13
const ACTION_STRIP_CONTAINER_CSS = 'igx-action-strip__actions' ;
13
14
const DROP_DOWN_LIST = 'igx-drop-down__list' ;
@@ -20,33 +21,48 @@ describe('igxActionStrip', () => {
20
21
let innerContainer : ViewContainerRef ;
21
22
22
23
describe ( 'Unit tests: ' , ( ) => {
23
- const mockViewContainerRef = jasmine . createSpyObj ( 'ViewContainerRef' , [ 'element' ] ) ;
24
- const mockRenderer2 = jasmine . createSpyObj ( 'Renderer2' , [ 'appendChild' , 'removeChild' ] ) ;
25
- const mockContext = jasmine . createSpyObj ( 'context' , [ 'element' ] ) ;
26
- const mockDisplayDensity = jasmine . createSpyObj ( 'IDisplayDensityOptions' , [ 'displayDensity' ] ) ;
27
- const cdr = jasmine . createSpyObj ( 'ChangeDetectorRef' , [ 'detectChanges' ] ) ;
28
-
29
- it ( 'should properly get/set hidden' , ( ) => {
30
- actionStrip = new IgxActionStripComponent ( mockViewContainerRef , mockRenderer2 , mockDisplayDensity , cdr ) ;
31
- expect ( actionStrip . hidden ) . toBeFalsy ( ) ;
32
- actionStrip . hidden = true ;
33
- expect ( actionStrip . hidden ) . toBeTruthy ( ) ;
24
+
25
+ configureTestSuite ( ( ) => {
26
+ return TestBed . configureTestingModule ( {
27
+ declarations : [
28
+ IgxActionStripComponent
29
+ ] ,
30
+ imports : [
31
+ NoopAnimationsModule ,
32
+ IgxDropDownModule
33
+ ]
34
+ } ) ;
34
35
} ) ;
35
36
37
+ // This test is only testing whether a setter ran. Removing it
38
+ // it('should properly get/set hidden', () => {
39
+ // fixture = TestBed.createComponent(IgxActionStripComponent);
40
+ // actionStrip = fixture.componentInstance as IgxActionStripComponent;
41
+ // fixture.detectChanges();
42
+ // expect(actionStrip.hidden).toBeFalsy();
43
+ // actionStrip.hidden = true;
44
+ // expect(actionStrip.hidden).toBeTruthy();
45
+ // });
46
+
36
47
it ( 'should properly show and hide using API' , ( ) => {
37
- actionStrip = new IgxActionStripComponent ( mockViewContainerRef , mockRenderer2 , mockDisplayDensity , cdr ) ;
38
- actionStrip . show ( mockContext ) ;
48
+ fixture = TestBed . createComponent ( IgxActionStripComponent ) ;
49
+ actionStrip = fixture . componentInstance as IgxActionStripComponent ;
50
+ fixture . detectChanges ( ) ;
51
+
52
+ const el = document . createElement ( 'div' ) ;
53
+ fixture . debugElement . nativeElement . appendChild ( el ) ;
54
+ actionStrip . show ( el ) ;
39
55
expect ( actionStrip . hidden ) . toBeFalsy ( ) ;
40
- expect ( actionStrip . context ) . toBe ( mockContext ) ;
56
+ expect ( actionStrip . context ) . toBe ( el ) ;
41
57
actionStrip . hide ( ) ;
42
58
expect ( actionStrip . hidden ) . toBeTruthy ( ) ;
59
+ fixture . debugElement . nativeElement . removeChild ( el ) ;
43
60
} ) ;
44
61
} ) ;
45
62
46
63
describe ( 'Initialization and rendering tests: ' , ( ) => {
47
- configureTestSuite ( ) ;
48
- beforeAll ( waitForAsync ( ( ) => {
49
- TestBed . configureTestingModule ( {
64
+ configureTestSuite ( ( ) => {
65
+ return TestBed . configureTestingModule ( {
50
66
declarations : [
51
67
IgxActionStripTestingComponent
52
68
] ,
@@ -56,16 +72,18 @@ describe('igxActionStrip', () => {
56
72
NoopAnimationsModule ,
57
73
IgxToggleModule
58
74
]
59
- } ) . compileComponents ( ) ;
60
- } ) ) ;
61
- beforeEach ( fakeAsync ( ( ) => {
75
+ } )
76
+ } ) ;
77
+
78
+ beforeEach ( ( ) => {
62
79
fixture = TestBed . createComponent ( IgxActionStripTestingComponent ) ;
63
80
fixture . detectChanges ( ) ;
64
81
actionStrip = fixture . componentInstance . actionStrip ;
65
82
actionStripElement = fixture . componentInstance . actionStripElement ;
66
83
parentContainer = fixture . componentInstance . parentContainer ;
67
84
innerContainer = fixture . componentInstance . innerContainer ;
68
- } ) ) ;
85
+ } ) ;
86
+
69
87
it ( 'should be overlapping its parent container when no context is applied' , ( ) => {
70
88
const parentBoundingRect = parentContainer . nativeElement . getBoundingClientRect ( ) ;
71
89
const actionStripBoundingRect = actionStripElement . nativeElement . getBoundingClientRect ( ) ;
@@ -102,9 +120,8 @@ describe('igxActionStrip', () => {
102
120
} ) ;
103
121
104
122
describe ( 'render content as menu' , ( ) => {
105
- configureTestSuite ( ) ;
106
- beforeAll ( waitForAsync ( ( ) => {
107
- TestBed . configureTestingModule ( {
123
+ configureTestSuite ( ( ) => {
124
+ return TestBed . configureTestingModule ( {
108
125
declarations : [
109
126
IgxActionStripMenuTestingComponent ,
110
127
IgxActionStripCombinedMenuTestingComponent
@@ -115,8 +132,8 @@ describe('igxActionStrip', () => {
115
132
NoopAnimationsModule ,
116
133
IgxToggleModule
117
134
]
118
- } ) . compileComponents ( ) ;
119
- } ) ) ;
135
+ } ) ;
136
+ } ) ;
120
137
121
138
it ( 'should render tree-dot button which toggles the content as menu' , ( ) => {
122
139
fixture = TestBed . createComponent ( IgxActionStripMenuTestingComponent ) ;
0 commit comments