Skip to content

Commit

Permalink
Fix tests and add test for non deferring attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasMesquitaBorges authored and João Roberto committed Oct 29, 2020
1 parent 49a68dd commit 40f2d2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/Boilerplate/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h1>Test Background Image</h1>
<script src="https://github.com/renatomarinho/laravel-page-speed/test/Boilerplate/js/vendor/modernizr-3.5.0.min.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-3.2.1.min.js"><\/script>')</script>
<script src="https://github.com/renatomarinho/laravel-page-speed/test/Boilerplate/js/plugins.js"></script>
<script src="https://github.com/renatomarinho/laravel-page-speed/test/Boilerplate/js/plugins.js" data-pagespeed-no-defer></script>
<script src="https://github.com/renatomarinho/laravel-page-speed/test/Boilerplate/js/main.js"></script>

<button type="submit" value="1000" name="tip" class="btn"><img src="/images/1000coin.png"/></button>
Expand Down
11 changes: 6 additions & 5 deletions tests/Middleware/DeferJavascriptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

class DeferJavascriptTest extends TestCase
{
public function test_defer_javascript()
public function testDeferJavascript()
{
$response = $this->middleware->handle($this->request, $this->getNext());

$this->assertContains('Boilerplate/js/main.js" defer', $response->getContent());
$this->assertNotContains('analytics.js" async defer defer', $response->getContent());
$this->assertNotContains('analytics.js" async defer defer', $response->getContent());
$this->assertNotContains('<script defer>window.jQuery', $response->getContent());
$this->assertStringContainsString('Boilerplate/js/main.js" defer></script>', $response->getContent());
$this->assertStringContainsString('Boilerplate/js/plugins.js" data-pagespeed-no-defer></script>', $response->getContent());

$this->assertStringNotContainsString('analytics.js" async defer defer></script>', $response->getContent());
$this->assertStringNotContainsString('<script defer>window.jQuery', $response->getContent());
}

protected function getMiddleware()
Expand Down

0 comments on commit 40f2d2e

Please sign in to comment.