-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): adds test case for position:absolute containers
- Loading branch information
Can Kattwinkel
committed
Mar 4, 2019
1 parent
506f4ea
commit 8cc121f
Showing
8 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {browser} from 'protractor'; | ||
import {PosaPage} from './posa.po'; | ||
|
||
describe('with position:absolute container', () => { | ||
let page: PosaPage; | ||
|
||
beforeEach(() => { | ||
page = new PosaPage(); | ||
page.navigateToDev(); | ||
}); | ||
|
||
|
||
it('should recognize sticky ', async () => { | ||
page.navigateToDev(); | ||
await browser.executeScript('window.scrollTo(0,501);'); | ||
const hasStickyClass = await hasClass(page.getStickyElement(), 'is-sticky'); | ||
expect(hasStickyClass).toBe(true); | ||
}); | ||
|
||
|
||
}); | ||
|
||
// via https://stackoverflow.com/questions/20268128/how-to-test-if-an-element-has-class-using-protractor | ||
async function hasClass(element, cls) { | ||
const classes = await element.getAttribute('class'); | ||
return classes.split(' ').indexOf(cls) !== -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {browser, by, element} from 'protractor'; | ||
|
||
export class PosaPage { | ||
|
||
|
||
constructor() { | ||
const width = 1200; | ||
const height = 900; | ||
browser.driver.manage().window().setSize(width, height); | ||
} | ||
|
||
navigateToDev() { | ||
return browser.get('/posa'); | ||
} | ||
|
||
|
||
getStickyElement() { | ||
return element(by.css('.some-thing-sticky')); | ||
} | ||
|
||
getEnableButton() { | ||
return element(by.css('#enable-btn')); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/app/test-cases/posa-container/posa-container.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<p> | ||
I'm special, since the containing div scrolls and not the body. | ||
</p> | ||
|
||
|
||
<div class="row"> | ||
<div class="col-6"> | ||
<div #spacer></div> | ||
<div [spacer]="spacer" class="some-thing-sticky" stickyThing=""> | ||
Scroll by! | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> | ||
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> | ||
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> | ||
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> |
18 changes: 18 additions & 0 deletions
18
src/app/test-cases/posa-container/posa-container.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
:host { | ||
display: block; | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
height: 100%; | ||
overflow: auto; | ||
background-color: red; | ||
} | ||
|
||
|
||
.some-thing-sticky { | ||
background-color: #fff; | ||
padding: 15px; | ||
color: #000; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/app/test-cases/posa-container/posa-container.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import {PosaContainerComponent} from './posa-container.component'; | ||
|
||
describe('PosaContainerComponent', () => { | ||
let component: PosaContainerComponent; | ||
let fixture: ComponentFixture<PosaContainerComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [PosaContainerComponent] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(PosaContainerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
src/app/test-cases/posa-container/posa-container.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'demo-posa-container', | ||
templateUrl: './posa-container.component.html', | ||
styleUrls: ['./posa-container.component.scss'] | ||
}) | ||
export class PosaContainerComponent implements OnInit { | ||
|
||
constructor() { | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |