function ComponentRenderTest::testJsLibraryAttachesCorrectly
Same name in this branch
- 10 core/tests/Drupal/FunctionalJavascriptTests/Components/ComponentRenderTest.php \Drupal\FunctionalJavascriptTests\Components\ComponentRenderTest::testJsLibraryAttachesCorrectly()
Same name in other branches
- 11.x core/modules/sdc/tests/src/FunctionalJavascript/ComponentRenderTest.php \Drupal\Tests\sdc\FunctionalJavascript\ComponentRenderTest::testJsLibraryAttachesCorrectly()
- 11.x core/tests/Drupal/FunctionalJavascriptTests/Components/ComponentRenderTest.php \Drupal\FunctionalJavascriptTests\Components\ComponentRenderTest::testJsLibraryAttachesCorrectly()
Tests that the correct libraries are put on the page using JS.
This also covers all the path translations necessary to produce the correct path to the assets.
File
-
core/
modules/ sdc/ tests/ src/ FunctionalJavascript/ ComponentRenderTest.php, line 52
Class
- ComponentRenderTest
- Tests the correct rendering of components.
Namespace
Drupal\Tests\sdc\FunctionalJavascriptCode
public function testJsLibraryAttachesCorrectly() {
$build = [
'#type' => 'inline_template',
'#template' => "{{ include('sdc_test:my-button', {\n text: 'Click'\n }, with_context = false) }}",
];
\Drupal::state()->set('sdc_test_component', $build);
$this->drupalGet('sdc-test-component');
$page = $this->getSession()
->getPage();
$page->find('css', '[data-component-id="sdc_test:my-button"]')
->click();
$this->assertSame('Click power (1)', $page->find('css', '[data-component-id="sdc_test:my-button"]')
->getText());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.