From 722bc3e74bedcaa932d41ecf771d735e810ad9dc Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Wed, 20 Jan 2016 11:35:40 +0100 Subject: [PATCH] More testing for assets --- tests/unit/Grav/Common/AssetsTest.php | 34 +++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/unit/Grav/Common/AssetsTest.php b/tests/unit/Grav/Common/AssetsTest.php index e3a02d094..b37008296 100644 --- a/tests/unit/Grav/Common/AssetsTest.php +++ b/tests/unit/Grav/Common/AssetsTest.php @@ -29,7 +29,7 @@ class AssetsTest extends \Codeception\TestCase\Test return $this->grav()['assets']; } - public function testAddingCSS() + public function testAddingAssets() { $assets = $this->assets(); @@ -39,19 +39,49 @@ class AssetsTest extends \Codeception\TestCase\Test $css = $assets->css(); $this->assertSame($css, '' . PHP_EOL); + $assets->add('test.js'); + $js = $assets->js(); + $this->assertSame($js, '' . PHP_EOL); + //test addCss(). Test adding asset to a separate group $assets->reset(); $assets->addCSS('test.css'); - $css = $assets->css(); $this->assertSame($css, '' . PHP_EOL); + //test addJs() + $assets->reset(); + $assets->addJs('test.js'); + $js = $assets->js(); + $this->assertSame($js, '' . PHP_EOL); + + //Test CSS Groups $assets->reset(); $assets->addCSS('test.css', null, true, 'footer'); $css = $assets->css(); $this->assertEmpty($css); $css = $assets->css('footer'); $this->assertSame($css, '' . PHP_EOL); + + //Test JS Groups + $assets->reset(); + $assets->addJs('test.js', null, true, null, 'footer'); + $js = $assets->js(); + $this->assertEmpty($js); + $js = $assets->js('footer'); + $this->assertSame($js, '' . PHP_EOL); + + //Test async / defer + $assets->reset(); + $assets->addJs('test.js', null, true, 'async', null); + $js = $assets->js(); + $this->assertSame($js, '' . PHP_EOL); + $assets->reset(); + $assets->addJs('test.js', null, true, 'defer', null); + $js = $assets->js(); + $this->assertSame($js, '' . PHP_EOL); + + } public function testPriorityOfAssets()