Skip to content

Commit 1e6bcfe

Browse files
committed
debugging ios8
1 parent 5b0ad1d commit 1e6bcfe

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

scripts/ci/build-and-test.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
set -e
2+
set -ex
33

44
echo "======= Starting build-and-test.sh ========================================"
55

@@ -22,8 +22,21 @@ if is_lint; then
2222
elif is_circular_deps_check; then
2323
npm run check-circular-deps
2424
elif is_e2e; then
25+
# Start up the e2e app. This will take some time.
26+
echo "Starting e2e app"
2527
MD_APP=e2e ng serve &
26-
sleep 20
28+
sleep 1
29+
30+
# Wait until the dist/ directory is created, indicating that the e2e app is ready.
31+
# Use the presence of `button.js` to determine whether the compiled output is ready to be served.
32+
echo "Waiting for e2e app to start"
33+
while [ ! -f ./dist/components/button/button.js ]
34+
do
35+
inotifywait -qt 2 -e create -e move ./dist/components/button/button.js
36+
done
37+
38+
# Run the e2e tests on the served e2e app.
39+
echo "Starting e2e tests"
2740
ng e2e
2841
else
2942
karma start test/karma.conf.js --single-run --no-auto-watch --reporters='dots'

src/components/grid-list/grid-list.spec.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {inject, async} from '@angular/core/testing';
22
import {TestComponentBuilder} from '@angular/compiler/testing';
3-
import {Component} from '@angular/core';
3+
import {Component, DebugElement} from '@angular/core';
44
import {By} from '@angular/platform-browser';
55

66
import {MD_GRID_LIST_DIRECTIVES, MdGridList} from './grid-list';
@@ -160,7 +160,7 @@ describe('MdGridList', () => {
160160

161161
// check horizontal gutter
162162
expect(getProp(tiles[0], 'width')).toBe('99.5px');
163-
expect(getProp(tiles[1], 'left')).toBe('100.5px');
163+
expect(getComputedLeft(tiles[1])).toBe(100.5);
164164

165165
// check vertical gutter
166166
expect(getProp(tiles[0], 'height')).toBe('100px');
@@ -186,7 +186,7 @@ describe('MdGridList', () => {
186186

187187
// check horizontal gutter
188188
expect(getProp(tiles[0], 'width')).toBe('99px');
189-
expect(getProp(tiles[1], 'left')).toBe('101px');
189+
expect(getComputedLeft(tiles[1])).toBe(101);
190190

191191
// check vertical gutter
192192
expect(getProp(tiles[0], 'height')).toBe('100px');
@@ -212,7 +212,7 @@ describe('MdGridList', () => {
212212

213213
// check horizontal gutter
214214
expect(getProp(tiles[0], 'width')).toBe('99px');
215-
expect(getProp(tiles[1], 'left')).toBe('101px');
215+
expect(getComputedLeft(tiles[1])).toBe(101);
216216

217217
// check vertical gutter
218218
expect(getProp(tiles[0], 'height')).toBe('100px');
@@ -317,22 +317,22 @@ describe('MdGridList', () => {
317317

318318
expect(getProp(tiles[0], 'width')).toBe('299.75px');
319319
expect(getProp(tiles[0], 'height')).toBe('100px');
320-
expect(getProp(tiles[0], 'left')).toBe('0px');
320+
expect(getComputedLeft(tiles[0])).toBe(0);
321321
expect(getProp(tiles[0], 'top')).toBe('0px');
322322

323323
expect(getProp(tiles[1], 'width')).toBe('99.25px');
324324
expect(getProp(tiles[1], 'height')).toBe('201px');
325-
expect(getProp(tiles[1], 'left')).toBe('300.75px');
325+
expect(getComputedLeft(tiles[1])).toBe(300.75);
326326
expect(getProp(tiles[1], 'top')).toBe('0px');
327327

328328
expect(getProp(tiles[2], 'width')).toBe('99.25px');
329329
expect(getProp(tiles[2], 'height')).toBe('100px');
330-
expect(getProp(tiles[2], 'left')).toBe('0px');
330+
expect(getComputedLeft(tiles[2])).toBe(0);
331331
expect(getProp(tiles[2], 'top')).toBe('101px');
332332

333333
expect(getProp(tiles[3], 'width')).toBe('199.5px');
334334
expect(getProp(tiles[3], 'height')).toBe('100px');
335-
expect(getProp(tiles[3], 'left')).toBe('100.25px');
335+
expect(getComputedLeft(tiles[3])).toBe(100.25);
336336
expect(getProp(tiles[3], 'top')).toBe('101px');
337337
});
338338
});
@@ -389,6 +389,18 @@ class TestGridList {
389389
rowspan: number;
390390
}
391391

392-
function getProp(el: any, prop: string): string {
392+
function getProp(el: DebugElement, prop: string): string {
393393
return getComputedStyle(el.nativeElement).getPropertyValue(prop);
394394
}
395+
396+
/** Gets the `left` position of an element. */
397+
function getComputedLeft(element: DebugElement): number {
398+
// While the other properties in this test use `getComputedStyle`, we use `getBoundingClientRect`
399+
// for left because iOS Safari doesn't support using `getComputedStyle` to get the calculated
400+
// `left` balue when using CSS `calc`. We subtract the `left` of the document body because
401+
// browsers, by default, add a margin to the body (typically 8px).
402+
let elementRect = element.nativeElement.getBoundingClientRect();
403+
let bodyRect = document.body.getBoundingClientRect();
404+
405+
return elementRect.left - bodyRect.left;
406+
}

0 commit comments

Comments
 (0)