Skip to content

Commit 454aa09

Browse files
test(end to end): updated ene to end tests to match updated app and image-loader component functiona
1 parent b420de7 commit 454aa09

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

e2e/app.e2e-spec.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ describe('ImageLoader Lib E2E Tests', function () {
1616
});
1717
});
1818

19+
describe('placeholder image', () => {
20+
beforeEach(() => page.setWindowSize(300, 580));
21+
22+
it('should load placeholder image', () => {
23+
expect(page.getImageElement().getAttribute('src')).toEqual('http://via.placeholder.com/35x15?text=placeholder');
24+
});
25+
26+
it('should update placeholder loaded boolean on init', () => {
27+
expect(page.getplaceholderBooleanElement().getText()).toEqual('true');
28+
});
29+
});
30+
1931
describe('lazy load image', () => {
2032
beforeEach(() => page.setWindowSize(300, 580));
2133

@@ -36,13 +48,24 @@ describe('ImageLoader Lib E2E Tests', function () {
3648
expect(imgSrc).toEqual('http://via.placeholder.com/150x350?text=xs+1x 1x, http://via.placeholder.com/300x700?text=xs+2x 2x');
3749

3850
});
51+
52+
it('should update full res image event count on when in viewport', () => {
53+
expect(page.getFullResCountElement().getText()).toEqual('0');
54+
55+
page.scrollTo(0, 580 * 1.5)
56+
.then(() => {
57+
browser.wait(() => page.getLoadedImageElement());
58+
});
59+
60+
expect(page.getFullResCountElement().getText()).toEqual('1');
61+
});
62+
3963
});
4064

4165
describe('responsive image', () => {
4266
beforeEach(() => page.setWindowSize(300, 580));
4367

4468
it('should load correct image for device size', () => {
45-
4669
page.scrollTo(0, 580 * 1.5)
4770
.then(() => {
4871
browser.wait(() => page.getLoadedImageElement());
@@ -70,38 +93,27 @@ describe('ImageLoader Lib E2E Tests', function () {
7093
expect(imgSrc).toEqual('http://via.placeholder.com/700x400?text=lg+1x 1x, http://via.placeholder.com/1400x800?text=lg+2x 2x');
7194
});
7295

73-
});
74-
75-
describe('iamge loaded', () => {
76-
beforeEach(() => page.setWindowSize(300, 580));
96+
it('should update image loaded event count on window resize when image in viewport', () => {
97+
expect(page.getFullResCountElement().getText()).toEqual('0');
7798

78-
it('should fire an event on placeholder image load', () => {
79-
expect(page.getCountElement().getText()).toEqual('1');
80-
});
81-
82-
it('should update image loaded event count on when image in viewport', () => {
8399
page.scrollTo(0, 580 * 1.5)
84100
.then(() => {
85101
browser.wait(() => page.getLoadedImageElement());
86102
});
87-
expect(page.getCountElement().getText()).toEqual('2');
88-
});
89103

90-
it('should update image loaded event count on image load on window resize when image in viewport', () => {
104+
expect(page.getFullResCountElement().getText()).toEqual('1');
91105

92-
page.scrollTo(0, 580 * 1.5)
93-
.then(() => page.setWindowSize(768, 580))
106+
page.setWindowSize(768, 580)
94107
.then(() => {
95108
browser.wait(() => page.getLoadedImageElement());
96109
});
97-
expect(page.getCountElement().getText()).toEqual('3');
110+
expect(page.getFullResCountElement().getText()).toEqual('2');
98111

99112
page.setWindowSize(1024, 580)
100113
.then(() => {
101114
browser.wait(() => page.getLoadedImageElement());
102115
});
103-
expect(page.getCountElement().getText()).toEqual('4');
104-
116+
expect(page.getFullResCountElement().getText()).toEqual('3');
105117
});
106118

107119
});

e2e/app.po.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export class AppPage {
2525
return element(by.css('.sn-image-loaded')).isPresent();
2626
}
2727

28-
getCountElement() {
29-
return element(by.css('.count'));
28+
getplaceholderBooleanElement() {
29+
return element(by.css('.placeholder-boolean'));
30+
}
31+
32+
getFullResCountElement() {
33+
return element(by.css('.full-res-count'));
3034
}
3135
}

0 commit comments

Comments
 (0)