Skip to content

Commit d522edd

Browse files
author
alexander.bachmann
committed
added test for scss scoped import fixed test canges caused by scssphp 1.4.0
1 parent b159fd2 commit d522edd

File tree

8 files changed

+69
-4
lines changed

8 files changed

+69
-4
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Paneon\VueToTwig\Tests;
4+
5+
use Exception;
6+
use Paneon\VueToTwig\Utils\StyleBuilder;
7+
8+
class CompilerStyleBlockScopedImportTest extends AbstractTestCase
9+
{
10+
/**
11+
* @dataProvider dataProvider
12+
*
13+
* @param mixed $html
14+
* @param mixed $expected
15+
*
16+
* @throws Exception
17+
*/
18+
public function testStyleBlock($html, $expected)
19+
{
20+
$compiler = $this->createCompiler($html);
21+
$compiler->setStyleBlockOutputType(StyleBuilder::STYLE_ALL);
22+
$compiler->setRelativePath(__DIR__ . '/fixtures/style-block-scoped-import/style-block-scss-scoped-import.vue');
23+
24+
$actual = $compiler->convert();
25+
26+
$this->assertEqualHtml($expected, $actual);
27+
}
28+
29+
/**
30+
* @return array
31+
*/
32+
public function dataProvider()
33+
{
34+
return $this->loadFixturesFromDir('style-block-scoped-import');
35+
}
36+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$red: #FF0000;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<style>.foo[data-v-ebb65c10cf7f8655fefc2dd8f1dcbde2] { color: blue;}.foo__bar[data-v-ebb65c10cf7f8655fefc2dd8f1dcbde2] { color: #FF0000;}</style>
2+
<div data-v-ebb65c10cf7f8655fefc2dd8f1dcbde2 {{ dataScopedStyleAttribute|default('') }} class="{{ class|default('') }}" style="{{ style|default('') }}">
3+
<div class="foo__bar" data-v-ebb65c10cf7f8655fefc2dd8f1dcbde2>
4+
baz
5+
</div>
6+
</div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<div>
3+
<div class="foo__bar">
4+
baz
5+
</div>
6+
</div>
7+
</template>
8+
9+
<style lang="scss" scoped>
10+
@import "import";
11+
.foo {
12+
color: blue;
13+
&__bar {
14+
color: $red;
15+
}
16+
}
17+
</style>
18+
19+
<script>
20+
export default {
21+
}
22+
</script>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<style>.grow-enter[data-v-de62703e2bdacde95c4bc73d69f14aa5], .grow-leave-to[data-v-de62703e2bdacde95c4bc73d69f14aa5] { width: 0 !important; }.grow-enter-active[data-v-de62703e2bdacde95c4bc73d69f14aa5], .grow-leave-active[data-v-de62703e2bdacde95c4bc73d69f14aa5] { transition: width 0.6s ease; }</style>
1+
<style>.grow-enter[data-v-de62703e2bdacde95c4bc73d69f14aa5], .grow-leave-to[data-v-de62703e2bdacde95c4bc73d69f14aa5] { width: 0 !important;}.grow-enter-active[data-v-de62703e2bdacde95c4bc73d69f14aa5], .grow-leave-active[data-v-de62703e2bdacde95c4bc73d69f14aa5] { transition: width 0.6s ease;}</style>
22
<div class="bar {{ class|default('') }}" data-v-de62703e2bdacde95c4bc73d69f14aa5 {{ dataScopedStyleAttribute|default('') }} style="{{ style|default('') }}"></div>

tests/fixtures/style-block-scoped/style-block-scss-scoped.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<style>.foo[data-v-bc2fd2697c25be635fabb11cba6f24b9] { color: red; } .foo__bar[data-v-bc2fd2697c25be635fabb11cba6f24b9] { color: blue; } .foo__baz[data-v-bc2fd2697c25be635fabb11cba6f24b9] { color: #00FF00; }</style>
1+
<style>.foo[data-v-bc2fd2697c25be635fabb11cba6f24b9] { color: red;}.foo__bar[data-v-bc2fd2697c25be635fabb11cba6f24b9] { color: blue;}.foo__baz[data-v-bc2fd2697c25be635fabb11cba6f24b9] { color: #00FF00;}</style>
22
<div data-v-bc2fd2697c25be635fabb11cba6f24b9 {{ dataScopedStyleAttribute|default('') }} class="{{ class|default('') }}" style="{{ style|default('') }}">
33
<div class="foo__bar" data-v-bc2fd2697c25be635fabb11cba6f24b9>
44
baz

tests/fixtures/style-block-scoped/style-blocks.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<style> .foo { color: red; }</style>
22
<style> .bar[data-v-d90c32720cdc50ff836bde94d71a2bb5] { color: blue; }</style>
3-
<style>.baz { color: #00FF00; }</style>
3+
<style>.baz { color: #00FF00;}</style>
44
<div data-v-d90c32720cdc50ff836bde94d71a2bb5 {{ dataScopedStyleAttribute|default('') }} class="{{ class|default('') }}" style="{{ style|default('') }}">
55
<div class="foo bar baz" data-v-d90c32720cdc50ff836bde94d71a2bb5>
66
42

tests/fixtures/style-block/style-block-scss.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<style>.foo { color: red; } .foo__bar { color: blue; } .foo__baz { color: #00FF00; }</style>
1+
<style>.foo { color: red;}.foo__bar { color: blue;}.foo__baz { color: #00FF00;}</style>
22
<div class="{{ class|default('') }}" style="{{ style|default('') }}">
33
<div class="foo">
44
foo

0 commit comments

Comments
 (0)