|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 | 8 |
|
9 |
| -import {TestBed, inject} from '@angular/core/testing'; |
| 9 | +import {TestBed, inject, async} from '@angular/core/testing'; |
10 | 10 |
|
11 | 11 | import {BreakPoint} from '../break-point';
|
12 | 12 | import {DEFAULT_BREAKPOINTS} from './break-points';
|
@@ -70,45 +70,44 @@ describe('break-point-provider', () => {
|
70 | 70 |
|
71 | 71 | describe('with custom breakpoint overrides', () => {
|
72 | 72 | const gtXsMediaQuery = 'screen and (max-width:20px) and (orientations: landscape)';
|
73 |
| - const mdMediaQuery = 'print and (min-width:10000px)'; |
| 73 | + const xxxlQuery = 'screen and (min-width:10000px)'; |
74 | 74 | const EXTRAS: BreakPoint[] = [
|
75 |
| - {alias: 'md', mediaQuery: mdMediaQuery}, |
76 |
| - {alias: 'gt-xs', mediaQuery: gtXsMediaQuery}, |
77 |
| - {alias: 'lt-ab', mediaQuery: '(max-width: 297px)'}, |
78 |
| - {alias: 'cd', mediaQuery: '(min-width: 298px) and (max-width:414px)'} |
| 75 | + {alias: 'xxl', priority: 2000, mediaQuery: xxxlQuery}, |
| 76 | + {alias: 'gt-xsl', priority: 2000, mediaQuery: gtXsMediaQuery}, |
| 77 | + {alias: 'lt-ab', priority: 2000, mediaQuery: '(max-width: 297px)'}, |
| 78 | + {alias: 'cd', priority: 2000, mediaQuery: '(min-width: 298px) and (max-width:414px)'} |
79 | 79 | ];
|
80 |
| - const NUM_EXTRAS = 2; // since md and gt-xs will not be added but merged |
81 | 80 | let bpList: BreakPoint[];
|
82 | 81 | let accumulator: BreakPoint | null = null;
|
83 | 82 | let byAlias = (alias: string): BreakPoint | null => bpList.reduce((pos, it) => {
|
84 | 83 | return pos || ((it.alias === alias) ? it : null);
|
85 | 84 | }, accumulator);
|
86 | 85 |
|
87 |
| - beforeEach(() => { |
| 86 | + beforeEach(async (() => { |
88 | 87 | // Configure testbed to prepare services
|
89 | 88 | TestBed.configureTestingModule({
|
90 | 89 | imports: [FlexLayoutModule.withConfig({addOrientationBps: true}, EXTRAS)]
|
91 | 90 | });
|
92 |
| - }); |
| 91 | + })); |
93 | 92 | // tslint:disable-next-line:no-shadowed-variable
|
94 | 93 | beforeEach(inject([BREAKPOINTS], (breakPoints: BreakPoint[]) => {
|
95 | 94 | bpList = breakPoints;
|
96 | 95 | }));
|
97 | 96 |
|
98 | 97 | it('has merged the custom breakpoints as overrides to existing defaults', () => {
|
99 |
| - const total = ORIENTATION_BREAKPOINTS.length + DEFAULT_BREAKPOINTS.length + NUM_EXTRAS; |
| 98 | + const total = ORIENTATION_BREAKPOINTS.length + DEFAULT_BREAKPOINTS.length + EXTRAS.length; |
100 | 99 |
|
101 | 100 | expect(bpList.length).toEqual(total);
|
102 | 101 |
|
103 |
| - expect(byAlias('gt-xs')).toBeDefined(); |
104 |
| - expect(byAlias('gt-xs')!.mediaQuery).toEqual(gtXsMediaQuery); |
| 102 | + expect(byAlias('gt-xsl')).toBeDefined(); |
| 103 | + expect(byAlias('gt-xsl')!.mediaQuery).toEqual(gtXsMediaQuery); |
105 | 104 |
|
106 |
| - expect(byAlias('md')).toBeDefined(); |
107 |
| - expect(byAlias('md')!.mediaQuery).toEqual(mdMediaQuery); |
| 105 | + expect(byAlias('xxl')).toBeDefined(); |
| 106 | + expect(byAlias('xxl')!.mediaQuery).toEqual(xxxlQuery); |
108 | 107 | });
|
109 | 108 |
|
110 | 109 | it('can extend existing default breakpoints with custom settings', () => {
|
111 |
| - const total = ORIENTATION_BREAKPOINTS.length + DEFAULT_BREAKPOINTS.length + NUM_EXTRAS; |
| 110 | + const total = ORIENTATION_BREAKPOINTS.length + DEFAULT_BREAKPOINTS.length + EXTRAS.length; |
112 | 111 |
|
113 | 112 | expect(bpList.length).toEqual(total);
|
114 | 113 | expect(bpList[bpList.length - 2].alias).toEqual('lt-ab');
|
|
0 commit comments