@@ -33,19 +33,33 @@ describe('MatTabBody', () => {
33
33
describe ( 'when initialized as center' , ( ) => {
34
34
let fixture : ComponentFixture < SimpleTabBodyApp > ;
35
35
36
+ it ( 'should be center position if origin is unchanged' , ( ) => {
37
+ fixture = TestBed . createComponent ( SimpleTabBodyApp ) ;
38
+ fixture . componentInstance . position = 0 ;
39
+ fixture . detectChanges ( ) ;
40
+
41
+ expect ( fixture . componentInstance . tabBody . _position ) . toBe ( 'center' ) ;
42
+ } ) ;
43
+
44
+ it ( 'should be center position if origin is explicitly set to null' , ( ) => {
45
+ fixture = TestBed . createComponent ( SimpleTabBodyApp ) ;
46
+ fixture . componentInstance . position = 0 ;
47
+
48
+ // It can happen that the `origin` is explicitly set to null through the Angular input
49
+ // binding. This test should ensure that the body does properly such origin value.
50
+ // The `MatTab` class sets the origin by default to null. See related issue: #12455
51
+ fixture . componentInstance . origin = null ;
52
+ fixture . detectChanges ( ) ;
53
+
54
+ expect ( fixture . componentInstance . tabBody . _position ) . toBe ( 'center' ) ;
55
+ } ) ;
56
+
36
57
describe ( 'in LTR direction' , ( ) => {
58
+
37
59
beforeEach ( ( ) => {
38
60
dir = 'ltr' ;
39
61
fixture = TestBed . createComponent ( SimpleTabBodyApp ) ;
40
62
} ) ;
41
-
42
- it ( 'should be center position without origin' , ( ) => {
43
- fixture . componentInstance . position = 0 ;
44
- fixture . detectChanges ( ) ;
45
-
46
- expect ( fixture . componentInstance . tabBody . _position ) . toBe ( 'center' ) ;
47
- } ) ;
48
-
49
63
it ( 'should be left-origin-center position with negative or zero origin' , ( ) => {
50
64
fixture . componentInstance . position = 0 ;
51
65
fixture . componentInstance . origin = 0 ;
@@ -176,7 +190,7 @@ describe('MatTabBody', () => {
176
190
class SimpleTabBodyApp implements AfterContentInit {
177
191
content : TemplatePortal ;
178
192
position : number ;
179
- origin : number ;
193
+ origin : number | null ;
180
194
181
195
@ViewChild ( MatTabBody ) tabBody : MatTabBody ;
182
196
@ViewChild ( TemplateRef ) template : TemplateRef < any > ;
0 commit comments