-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #979 from shufo/fix/js-directive-support
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { describe, test } from "vitest"; | ||
import * as util from "../support/util"; | ||
|
||
describe("formatter js test", () => { | ||
test("basic @js directive usage", async () => { | ||
const content = [`<div x-data="@js($data, JSON_FORCE_OBJECT)"></div>`].join( | ||
"\n", | ||
); | ||
|
||
const expected = [ | ||
`<div x-data="@js($data, JSON_FORCE_OBJECT)"></div>`, | ||
"", | ||
].join("\n"); | ||
|
||
await util.doubleFormatCheck(content, expected); | ||
}); | ||
|
||
test("@js directive in script tag", async () => { | ||
const content = [ | ||
"<script>", | ||
" @foreach ($files as $file)", | ||
" addUpload(", | ||
" @js($file->id),", | ||
" @js($file->name),", | ||
" @js($file->hash),", | ||
" $('#article_inline_uploads')", | ||
" );", | ||
" @endforeach", | ||
"</script>", | ||
].join("\n"); | ||
|
||
const expected = [ | ||
"<script>", | ||
" @foreach ($files as $file)", | ||
" addUpload(", | ||
" @js($file->id),", | ||
" @js($file->name),", | ||
" @js($file->hash),", | ||
" $('#article_inline_uploads')", | ||
" );", | ||
" @endforeach", | ||
"</script>", | ||
"", | ||
].join("\n"); | ||
|
||
await util.doubleFormatCheck(content, expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters