You are here

public function Select2WidgetTest::testEmptyField in Select 2 8

Test rendering of an empty field.

@group select2

File

tests/src/FunctionalJavascript/FieldWidget/Select2WidgetTest.php, line 19

Class

Select2WidgetTest
Tests select2 simple widget.

Namespace

Drupal\Tests\select2\FunctionalJavascript\FieldWidget

Code

public function testEmptyField() {
  $this
    ->createField('select2', 'node', 'test', 'list_string', [], [], 'select2', []);
  $this
    ->drupalGet('/node/add/test');

  // Without the placeholder field is the widget not correctly initialized.
  $this
    ->assertSession()
    ->elementExists('css', '.form-item-select2 .select2-selection__placeholder');
  $this
    ->scrollElementInView('.form-item-select2 .select2-selection.select2-selection--single');
  $this
    ->click('.form-item-select2 .select2-selection.select2-selection--single');
  $this
    ->assertSession()
    ->elementTextContains('css', '.select2-dropdown .select2-results', 'No results found');
}