|
| 1 | +/** |
| 2 | + * Copyright 2019 The AMP HTML Authors. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS-IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +describes.endtoend( |
| 18 | + 'amp-list "amp-script:" uri', |
| 19 | + { |
| 20 | + testUrl: 'http://localhost:8000/test/fixtures/e2e/amp-list/amp-list-function-src.html', |
| 21 | + experiments: ['protocol-adapters'], |
| 22 | + environments: ['single'], |
| 23 | + }, |
| 24 | + async (env) => { |
| 25 | + let controller; |
| 26 | + |
| 27 | + beforeEach(async () => { |
| 28 | + controller = env.controller; |
| 29 | + }); |
| 30 | + |
| 31 | + it.configure() |
| 32 | + .run('should render list backed by amp-script data', async function () { |
| 33 | + const container = await getListContainer(controller); |
| 34 | + await verifyContainer(controller, container); |
| 35 | + |
| 36 | + // Verify that all items rendered. |
| 37 | + const listItems = await getListItems(controller); |
| 38 | + await expect(listItems).to.have.length(2); |
| 39 | + }); |
| 40 | + } |
| 41 | +); |
| 42 | + |
| 43 | +function getListContainer(controller) { |
| 44 | + return controller.findElement('div[role=list]'); |
| 45 | +} |
| 46 | + |
| 47 | +function getListItems(controller) { |
| 48 | + return controller.findElements('div[role=listitem]'); |
| 49 | +} |
| 50 | + |
| 51 | +async function verifyContainer(controller, container) { |
| 52 | + await expect(controller.getElementAttribute(container, 'class')).to.equal( |
| 53 | + 'i-amphtml-fill-content i-amphtml-replaced-content' |
| 54 | + ); |
| 55 | +} |
0 commit comments