-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Micajuine Ho
committed
Nov 3, 2020
1 parent
15148c3
commit ba5d222
Showing
3 changed files
with
132 additions
and
23 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,66 @@ | ||
/** | ||
* Copyright 2020 The AMP HTML Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS-IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import {getNextArrow, getPrevArrow, getSlides} from './helpers'; | ||
import sleep from 'sleep-promise'; | ||
|
||
const pageWidth = 500; | ||
const pageHeight = 800; | ||
|
||
describes.endtoend( | ||
'AMP carousel advance', | ||
{ | ||
testUrl: | ||
'http://localhost:8000/test/manual/amp-base-carousel/advance.amp.html', | ||
experiments: ['amp-base-carousel'], | ||
environments: ['single'], | ||
initialRect: {width: pageWidth, height: pageHeight}, | ||
}, | ||
async (env) => { | ||
let controller; | ||
let nextArrow; | ||
let prevArrow; | ||
|
||
function css(handle, name) { | ||
return controller.getElementCssValue(handle, name); | ||
} | ||
|
||
function rect(el) { | ||
return controller.getElementRect(el); | ||
} | ||
|
||
beforeEach(async () => { | ||
controller = env.controller; | ||
|
||
nextArrow = await getNextArrow(controller); | ||
}); | ||
|
||
it('should move forwards once', async () => { | ||
await controller.click(nextArrow); | ||
await sleep(500); | ||
prevArrow = await getPrevArrow(controller); | ||
await expect(css(prevArrow, 'opacity')).to.equal('1'); | ||
await expect(css(nextArrow, 'opacity')).to.equal('1'); | ||
|
||
const slides = await getSlides(controller); | ||
const slideOne = await rect(slides[0]); | ||
const slideTwo = await rect(slides[1]); | ||
|
||
await expect(slideOne['x']).to.be.lessThan(0); | ||
await expect(slideTwo['x']).to.be.at.least(0); | ||
}); | ||
} | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!doctype html> | ||
<html ⚡> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>My AMP Page</title> | ||
<link rel="canonical" href="self.html" /> | ||
<script async custom-element="amp-base-carousel" src="https://cdn.ampproject.org/v0/amp-base-carousel-0.1.js"></script> | ||
<meta name="viewport" content="width=device-width,minimum-scale=1"> | ||
<script async src="https://cdn.ampproject.org/v0.js"></script> | ||
<style amp-custom> | ||
amp-base-carousel .item { | ||
padding: 40px; | ||
border: 1px solid black; | ||
} | ||
#wrapper { | ||
width: 400px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="wrapper"> | ||
<amp-base-carousel class="gallery" layout="responsive" width="33" height="10" visible-count="3.3" advance-count="1" loop="false"> | ||
<div class="item">1</div> | ||
<div class="item">2</div> | ||
<div class="item">3</div> | ||
<div class="item">4</div> | ||
<div class="item">5</div> | ||
<div class="item">6</div> | ||
<div class="item">7</div> | ||
<div class="item">8</div> | ||
<div class="item">9</div> | ||
<div class="item">10</div> | ||
<div class="item">11</div> | ||
<div class="item">12</div> | ||
<div class="item">13</div> | ||
</amp-base-carousel> | ||
</div> | ||
</body> | ||
|
||
</html> |