You are here

BlazyIoJavaScriptTest.php in Blazy 8.2

File

tests/src/FunctionalJavascript/BlazyIoJavaScriptTest.php
View source
<?php

namespace Drupal\Tests\blazy\FunctionalJavascript;


/**
 * Tests the Blazy IO JavaScript using PhantomJS, or Chromedriver.
 *
 * @group blazy
 */
class BlazyIoJavaScriptTest extends BlazyJavaScriptTestBase {

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->scriptLoader = 'io';

    // Enable IO support.
    $this->container
      ->get('config.factory')
      ->getEditable('blazy.settings')
      ->set('io.enabled', TRUE)
      ->save();
    $this->container
      ->get('config.factory')
      ->getEditable('blazy.settings')
      ->set('decode', TRUE)
      ->save();
    $this->container
      ->get('config.factory')
      ->clearStaticCache();
  }

  /**
   * Test the Blazy element from loading to loaded states.
   */
  public function testFormatterDisplay() {
    $data['settings']['blazy'] = TRUE;
    $data['settings']['ratio'] = '';
    $data['settings']['image_style'] = 'thumbnail';
    $this
      ->setUpContentTypeTest($this->bundle);
    $this
      ->setUpFormatterDisplay($this->bundle, $data);
    $this
      ->setUpContentWithItems($this->bundle);
    $this
      ->drupalGet('node/' . $this->entity
      ->id());

    // Ensures Blazy is not loaded on page load.
    // @todo with Native lazyload, b-loaded is enforced on page load. And
    // since the testing browser Chrome support it, it is irrelevant.
    // @todo $this->assertSession()->elementNotExists('css', '.b-loaded');
    $result = $this
      ->assertSession()
      ->waitForElement('css', '.b-lazy');
    $this
      ->assertNotEmpty($result);
    $this
      ->doTestFormatterDisplay();
  }

}

Classes

Namesort descending Description
BlazyIoJavaScriptTest Tests the Blazy IO JavaScript using PhantomJS, or Chromedriver.