/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/integration/test-toggle-display.js
47 строк
1 KB
Riley Jones
✅ ♻️ Merge test helpers files (#35985)
15 окт 2021, 01:35
Не верифицирован
15 окт 2021, 01:35
ae9ca1b
Код
Авторство
О чём код?
import {setInitialDisplay, toggle} from '#core/dom/style'; import {BrowserController} from '#testing/helpers/service'; describes.integration( 'toggle display helper', { body: '<amp-img src="/examples/img/hero@1x.jpg" width="289" height="216"></amp-img>', }, (env) => { let browser, doc; let img; beforeEach(async () => { const {win} = env; doc = win.document; browser = new BrowserController(win); await browser.waitForElementLayout('amp-img'); img = doc.querySelector('amp-img'); }); function expectToggleDisplay(el) { toggle(el, false); expect(el).to.have.display('none'); toggle(el, true); expect(el).to.not.have.display('none'); } it('toggles regular display', () => { expectToggleDisplay(img); }); it('toggles initial display style', () => { setInitialDisplay(img, 'inline-block'); expectToggleDisplay(img); }); it('toggles stylesheet display style', () => { const style = doc.createElement('style'); style.innerText = 'amp-img { display: inline-block !important; }'; doc.head.appendChild(style); expectToggleDisplay(img); }); } );