Skip to content

Commit

Permalink
fix(core): Add back in call to addDrupalExtensions (#13) (#14)
Browse files Browse the repository at this point in the history
* Add back in call to `addDrupalExtensions`

* added test case for drupal functions

Co-authored-by: Paul Sebborn <paul@zoocha.com>
  • Loading branch information
larowlan and psebborn committed Jan 30, 2024
1 parent 7ea49fa commit 0b1d13c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ const plugin = (options = {}) => {
${functions}
addDrupalExtensions(Twig);
// Disable caching.
Twig.cache(false);
Expand Down
5 changes: 5 additions & 0 deletions tests/__snapshots__/smoke.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Basic smoke test > Should recognise default Drupal functions 1`] = `
"
<p>Functions work</p>"
`;

exports[`Basic smoke test > Should support global context and functions 1`] = `
"<section>
<h1>Include</h1>
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/drupal-functions.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ attach_library('drupal/library') }}
<p>Functions work</p>
6 changes: 6 additions & 0 deletions tests/smoke.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Markup from "../dist/test.js"
import Error from "../dist/error.js"
import ErrorInclude from "../dist/errorInclude.js"
import drupalFunctions from "../dist/drupalFunctions.js"
import Menu from "../dist/menu.js"
import { describe, expect, it } from "vitest"

Expand Down Expand Up @@ -35,4 +36,9 @@ describe("Basic smoke test", () => {
expect(markup).toContain("Nested include")
expect(markup).toContain("IT WORKS!")
})
it("Should recognise default Drupal functions", () => {
const markup = drupalFunctions()
expect(markup).toMatchSnapshot()
expect(markup).toContain("Functions work")
})
})
4 changes: 4 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default defineConfig({
error: resolve(__dirname, "tests/fixtures/error.twig"),
menu: resolve(__dirname, "tests/fixtures/menu.twig"),
errorInclude: resolve(__dirname, "tests/fixtures/error-include.twig"),
drupalFunctions: resolve(
__dirname,
"tests/fixtures/drupal-functions.twig"
),
},
name: "vite-plugin-twig-drupal",
fileName: (_, entry) => `${entry}.js`,
Expand Down

0 comments on commit 0b1d13c

Please sign in to comment.