@@ -15,11 +15,10 @@ import {dispatchKeyboardEvent, dispatchMouseEvent} from '../testing/dispatch-eve
1515import {
1616 MdcSelectModule ,
1717 MdcSelect ,
18- MDC_SELECT_DEFAULT_OPTIONS ,
19- MdcSelectDefaultOptions
18+ MDC_SELECT_DEFAULT_OPTIONS
2019} from '@angular-mdc/web' ;
2120
22- function configureMdcSelectTestingModule ( declarations : any [ ] , providers : Provider [ ] = [ ] ) {
21+ function configureMdcTestingModule ( declarations : any [ ] , providers : Provider [ ] = [ ] ) {
2322 TestBed . configureTestingModule ( {
2423 imports : [
2524 MdcSelectModule ,
@@ -35,9 +34,10 @@ function configureMdcSelectTestingModule(declarations: any[], providers: Provide
3534
3635describe ( 'MdcSelectModule' , ( ) => {
3736 let fixture : ComponentFixture < any > ;
37+ let platform : { isBrowser : boolean } ;
3838
3939 beforeEach ( async ( ( ) => {
40- configureMdcSelectTestingModule ( [
40+ configureMdcTestingModule ( [
4141 SimpleTest ,
4242 SelectFormControl ,
4343 EnhancedSelect ,
@@ -46,6 +46,46 @@ describe('MdcSelectModule', () => {
4646 ] ) ;
4747 } ) ) ;
4848
49+ describe ( 'Tests for SSR' , ( ) => {
50+ let testDebugElement : DebugElement ;
51+ let testInstance : MdcSelect ;
52+ let testComponent : SimpleTest ;
53+
54+ beforeEach ( ( ) => {
55+ // Set the default Platform override that can be updated before component creation.
56+ platform = { isBrowser : false } ;
57+
58+ fixture = TestBed . createComponent ( SimpleTest ) ;
59+ fixture . detectChanges ( ) ;
60+
61+ testDebugElement = fixture . debugElement . query ( By . directive ( MdcSelect ) ) ;
62+ testInstance = testDebugElement . componentInstance ;
63+ testComponent = fixture . debugElement . componentInstance ;
64+ } ) ;
65+
66+ it ( '#should have mdc-select by default' , ( ) => {
67+ expect ( testDebugElement . nativeElement . classList )
68+ . toContain ( 'mdc-select' , 'Expected to have mdc-select' ) ;
69+ } ) ;
70+
71+ it ( '#should handle mouse events' , ( ) => {
72+ testInstance . focus ( ) ;
73+ dispatchKeyboardEvent ( testInstance . elementRef . nativeElement , 'keydown' , DOWN_ARROW ) ;
74+ fixture . detectChanges ( ) ;
75+ } ) ;
76+
77+ it ( '#should handle mouse events' , fakeAsync ( ( ) => {
78+ dispatchMouseEvent ( testInstance . _selectedText . root , 'click' ) ;
79+ fixture . detectChanges ( ) ;
80+ testInstance . focus ( ) ;
81+ dispatchKeyboardEvent ( testInstance . _selectedText . root , 'keydown' , DOWN_ARROW ) ;
82+ dispatchKeyboardEvent ( testInstance . elementRef . nativeElement , 'keydown' , DOWN_ARROW ) ;
83+ fixture . detectChanges ( ) ;
84+
85+ flush ( ) ;
86+ } ) ) ;
87+ } ) ;
88+
4989 describe ( 'basic behaviors' , ( ) => {
5090 let testDebugElement : DebugElement ;
5191 let testNativeElement : HTMLElement ;
@@ -329,7 +369,7 @@ describe('MdcSelectModule', () => {
329369} ) ;
330370
331371it ( 'should be able to provide default values through an injection token' , ( ) => {
332- configureMdcSelectTestingModule ( [ NgModelSelect ] , [ {
372+ configureMdcTestingModule ( [ NgModelSelect ] , [ {
333373 provide : MDC_SELECT_DEFAULT_OPTIONS ,
334374 useValue : {
335375 outlined : true
@@ -342,7 +382,7 @@ it('should be able to provide default values through an injection token', () =>
342382} ) ;
343383
344384it ( 'should be able to provide default values through an injection token' , ( ) => {
345- configureMdcSelectTestingModule ( [ NgModelSelect ] , [ {
385+ configureMdcTestingModule ( [ NgModelSelect ] , [ {
346386 provide : MDC_SELECT_DEFAULT_OPTIONS ,
347387 useValue : {
348388 outlined : null
0 commit comments