|
7 | 7 | */
|
8 | 8 | import {Component, Injectable, OnInit, PLATFORM_ID} from '@angular/core';
|
9 | 9 | import {CommonModule, isPlatformServer} from '@angular/common';
|
10 |
| -import {TestBed, ComponentFixture, inject, async} from '@angular/core/testing'; |
| 10 | +import {TestBed, ComponentFixture, inject, waitForAsync} from '@angular/core/testing'; |
11 | 11 | import {DIR_DOCUMENT} from '@angular/cdk/bidi';
|
12 | 12 | import {
|
13 | 13 | ɵMatchMedia as MatchMedia,
|
@@ -51,7 +51,12 @@ describe('layout-gap directive', () => {
|
51 | 51 |
|
52 | 52 | // Configure testbed to prepare services
|
53 | 53 | TestBed.configureTestingModule({
|
54 |
| - imports: [CommonModule, FlexLayoutModule], |
| 54 | + imports: [CommonModule, FlexLayoutModule.withConfig({ |
| 55 | + multiplier: { |
| 56 | + value: 4, |
| 57 | + unit: 'px', |
| 58 | + } |
| 59 | + })], |
55 | 60 | declarations: [TestLayoutGapComponent],
|
56 | 61 | providers: [
|
57 | 62 | MockMatchMediaProvider,
|
@@ -111,6 +116,25 @@ describe('layout-gap directive', () => {
|
111 | 116 | expectEl(nodes[2]).not.toHaveStyle({'margin-right': '0px'}, styler);
|
112 | 117 | });
|
113 | 118 |
|
| 119 | + it('should add gap styles to all children except the 1st child w/ multiplier', () => { |
| 120 | + let template = ` |
| 121 | + <div fxLayoutAlign='center center' fxLayoutGap='13x'> |
| 122 | + <div fxFlex></div> |
| 123 | + <div fxFlex></div> |
| 124 | + <div fxFlex></div> |
| 125 | + </div> |
| 126 | + `; |
| 127 | + createTestComponent(template); |
| 128 | + fixture.detectChanges(); |
| 129 | + |
| 130 | + let nodes = queryFor(fixture, '[fxFlex]'); |
| 131 | + expect(nodes.length).toEqual(3); |
| 132 | + expectEl(nodes[0]).toHaveStyle({'margin-right': '52px'}, styler); |
| 133 | + expectEl(nodes[1]).toHaveStyle({'margin-right': '52px'}, styler); |
| 134 | + expectEl(nodes[2]).not.toHaveStyle({'margin-right': '52px'}, styler); |
| 135 | + expectEl(nodes[2]).not.toHaveStyle({'margin-right': '0px'}, styler); |
| 136 | + }); |
| 137 | + |
114 | 138 | it('should add gap styles in proper order when order style is applied', () => {
|
115 | 139 | let template = `
|
116 | 140 | <div fxLayoutAlign='center center' fxLayoutGap='13px'>
|
@@ -149,7 +173,7 @@ describe('layout-gap directive', () => {
|
149 | 173 | expectEl(nodes[3]).not.toHaveStyle({'margin-right': '0px'}, styler);
|
150 | 174 | });
|
151 | 175 |
|
152 |
| - it('should add update gap styles when row items are removed', async(() => { |
| 176 | + it('should add update gap styles when row items are removed', waitForAsync(() => { |
153 | 177 | let template = `
|
154 | 178 | <div fxLayoutAlign='center center' fxLayoutGap='13px'>
|
155 | 179 | <div fxFlex *ngFor='let row of rows'></div>
|
@@ -181,7 +205,7 @@ describe('layout-gap directive', () => {
|
181 | 205 |
|
182 | 206 | }));
|
183 | 207 |
|
184 |
| - it('should add update gap styles when only 1 row is remaining', async(() => { |
| 208 | + it('should add update gap styles when only 1 row is remaining', waitForAsync(() => { |
185 | 209 | let template = `
|
186 | 210 | <div fxLayoutAlign='center center' fxLayoutGap='13px'>
|
187 | 211 | <div fxFlex *ngFor='let row of rows'></div>
|
@@ -509,6 +533,27 @@ describe('layout-gap directive', () => {
|
509 | 533 | expectNativeEl(fixture).toHaveStyle(expectedMargin, styler);
|
510 | 534 | });
|
511 | 535 |
|
| 536 | + it('should add gap styles correctly w/ multiplier', () => { |
| 537 | + let template = ` |
| 538 | + <div fxLayoutGap='13x grid'> |
| 539 | + <div fxFlex></div> |
| 540 | + <div fxFlex></div> |
| 541 | + <div fxFlex></div> |
| 542 | + </div> |
| 543 | + `; |
| 544 | + createTestComponent(template); |
| 545 | + fixture.detectChanges(); |
| 546 | + |
| 547 | + let nodes = queryFor(fixture, '[fxFlex]'); |
| 548 | + let expectedMargin = {'margin': '0px -52px -52px 0px'}; |
| 549 | + let expectedPadding = {'padding': '0px 52px 52px 0px'}; |
| 550 | + expect(nodes.length).toEqual(3); |
| 551 | + expectEl(nodes[0]).toHaveStyle(expectedPadding, styler); |
| 552 | + expectEl(nodes[1]).toHaveStyle(expectedPadding, styler); |
| 553 | + expectEl(nodes[2]).toHaveStyle(expectedPadding, styler); |
| 554 | + expectNativeEl(fixture).toHaveStyle(expectedMargin, styler); |
| 555 | + }); |
| 556 | + |
512 | 557 | it('should add gap styles correctly between option', () => {
|
513 | 558 | let template = `
|
514 | 559 | <div fxLayoutGap='13px 12px grid'>
|
|
0 commit comments