@@ -20,8 +20,8 @@ describe('Directionality', () => {
2020 it ( 'should read dir from the html element if not specified on the body' , ( ) => {
2121 fakeDocument . documentElement . dir = 'rtl' ;
2222
23- let fixture = TestBed . createComponent ( InjectsDirectionality ) ;
24- let testComponent = fixture . debugElement . componentInstance ;
23+ const fixture = TestBed . createComponent ( InjectsDirectionality ) ;
24+ const testComponent = fixture . debugElement . componentInstance ;
2525
2626 expect ( testComponent . dir . value ) . toBe ( 'rtl' ) ;
2727 } ) ;
@@ -30,23 +30,36 @@ describe('Directionality', () => {
3030 fakeDocument . documentElement . dir = 'ltr' ;
3131 fakeDocument . body . dir = 'rtl' ;
3232
33- let fixture = TestBed . createComponent ( InjectsDirectionality ) ;
34- let testComponent = fixture . debugElement . componentInstance ;
33+ const fixture = TestBed . createComponent ( InjectsDirectionality ) ;
34+ const testComponent = fixture . debugElement . componentInstance ;
3535
3636 expect ( testComponent . dir . value ) . toBe ( 'rtl' ) ;
3737 } ) ;
3838
3939 it ( 'should default to ltr if nothing is specified on either body or the html element' , ( ) => {
40- let fixture = TestBed . createComponent ( InjectsDirectionality ) ;
41- let testComponent = fixture . debugElement . componentInstance ;
40+ const fixture = TestBed . createComponent ( InjectsDirectionality ) ;
41+ const testComponent = fixture . debugElement . componentInstance ;
4242
4343 expect ( testComponent . dir . value ) . toBe ( 'ltr' ) ;
4444 } ) ;
45+
46+ it ( 'should complete the `change` stream on destroy' , ( ) => {
47+ const fixture = TestBed . createComponent ( InjectsDirectionality ) ;
48+ const spy = jasmine . createSpy ( 'complete spy' ) ;
49+ const subscription =
50+ fixture . componentInstance . dir . change . subscribe ( undefined , undefined , spy ) ;
51+
52+ fixture . componentInstance . dir . ngOnDestroy ( ) ;
53+ expect ( spy ) . toHaveBeenCalled ( ) ;
54+
55+ subscription . unsubscribe ( ) ;
56+ } ) ;
57+
4558 } ) ;
4659
4760 describe ( 'Dir directive' , ( ) => {
4861 it ( 'should provide itself as Directionality' , ( ) => {
49- let fixture = TestBed . createComponent ( ElementWithDir ) ;
62+ const fixture = TestBed . createComponent ( ElementWithDir ) ;
5063 const injectedDirectionality =
5164 fixture . debugElement . query ( By . directive ( InjectsDirectionality ) ) . componentInstance . dir ;
5265
@@ -56,7 +69,7 @@ describe('Directionality', () => {
5669 } ) ;
5770
5871 it ( 'should emit a change event when the value changes' , fakeAsync ( ( ) => {
59- let fixture = TestBed . createComponent ( ElementWithDir ) ;
72+ const fixture = TestBed . createComponent ( ElementWithDir ) ;
6073 const injectedDirectionality =
6174 fixture . debugElement . query ( By . directive ( InjectsDirectionality ) ) . componentInstance . dir ;
6275
0 commit comments