Skip to content

Commit

Permalink
replace generic tag tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rellafella committed Aug 9, 2024
1 parent f54587b commit 6abe20d
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 150 deletions.
21 changes: 21 additions & 0 deletions tests/GenericTags/__snapshots__/cache.snap.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% cache globally
using
key
craft.some.rather.long.property.chain.request.path
for
3
weeks
%}
{% for block in entry.myMatrixField %}
<p>
{{ block.text }}
</p>
{% endfor %}
{% endcache %}

{# prettier-ignore #}
{% cache globally using key craft.some.rather.long.property.chain.request.path for 3 weeks %}
{% for block in entry.myMatrixField %}
<p>{{ block.text }}</p>
{% endfor %}
{% endcache %}
4 changes: 4 additions & 0 deletions tests/GenericTags/__snapshots__/header.snap.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% header 'Cache-Control: max-age=' ~ (expiry.timestamp - now.timestamp) %}

{# prettier-ignore #}
{% header "Cache-Control: max-age=" ~ (expiry.timestamp - now.timestamp) %}
1 change: 1 addition & 0 deletions tests/GenericTags/__snapshots__/includeCssFile.snap.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% includeCssFile '/assets/css/layouts/' ~ entry.layout ~ '.css' %}
143 changes: 0 additions & 143 deletions tests/GenericTags/__snapshots__/jsfmt.spec.js.snap

This file was deleted.

10 changes: 10 additions & 0 deletions tests/GenericTags/__snapshots__/nav.snap.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% nav entry in entries %}
<li>
<a href="{{ entry.url }}">{{ entry.title }}</a>
{% ifchildren %}
<ul>
{% children %}
</ul>
{% endifchildren %}
</li>
{% endnav %}
8 changes: 8 additions & 0 deletions tests/GenericTags/__snapshots__/paginate.snap.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% paginate craft.entries.section('blog').limit(10) as pageInfo, pageEntries %}

{% paginate craft.entries.section('blog').limit(10)
as
pageInfo,
pageEntries,
pageProperties
%}
1 change: 1 addition & 0 deletions tests/GenericTags/__snapshots__/redirect.snap.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% redirect 'pricing' 301 %}
13 changes: 13 additions & 0 deletions tests/GenericTags/__snapshots__/switch.snap.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% switch matrixBlock.type %}
{% case 'text' %}
{{ matrixBlock.textField|markdown }}
{% case 'image' %}
{{ matrixBlock.image[0].getImg() }}
{% default %}
<p>
A font walks into a bar.
</p>
<p>
The bartender says, “Hey, we don’t serve your type in here!”
</p>
{% endswitch %}
65 changes: 58 additions & 7 deletions tests/GenericTags/jsfmt.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@
run_spec(__dirname, ["twig"], {
twigMultiTags: [
"nav,endnav",
"switch,case,default,endswitch",
"ifchildren,endifchildren",
"cache,endcache"
]
import { run_spec } from "tests_config/run_spec";
import { describe, expect, it } from "vitest";

/** @type {import('tests_config/run_spec').PrettierOptions} */
const formatOptions = {};

describe("Failing", () => {
it("handle cache tags", async () => {
const { actual, snapshotFile } = await run_spec(import.meta.url, {
source: "cache.twig",
formatOptions: {
twigMultiTags: ["cache,endcache"]
}
});
await expect(actual).toMatchFileSnapshot(snapshotFile);
});
it("handle header tags", async () => {
const { actual, snapshotFile } = await run_spec(import.meta.url, {
source: "header.twig"
});
await expect(actual).toMatchFileSnapshot(snapshotFile);
});
it("handle include css file tag", async () => {
const { actual, snapshotFile } = await run_spec(import.meta.url, {
source: "includeCssFile.twig"
});
await expect(actual).toMatchFileSnapshot(snapshotFile);
});
it("handle nav tag", async () => {
const { actual, snapshotFile } = await run_spec(import.meta.url, {
source: "nav.twig",
formatOptions: {
twigMultiTags: ["nav,endnav", "ifchildren, endifchildren"]
}
});
await expect(actual).toMatchFileSnapshot(snapshotFile);
});
it("handle paginate tag", async () => {
const { actual, snapshotFile } = await run_spec(import.meta.url, {
source: "paginate.twig"
});
await expect(actual).toMatchFileSnapshot(snapshotFile);
});
it("handle redirect tag", async () => {
const { actual, snapshotFile } = await run_spec(import.meta.url, {
source: "redirect.twig"
});
await expect(actual).toMatchFileSnapshot(snapshotFile);
});
it("handle switch tag", async () => {
const { actual, snapshotFile } = await run_spec(import.meta.url, {
source: "switch.twig",
formatOptions: {
twigMultiTags: ["switch,case,default,endswitch"]
}
});
await expect(actual).toMatchFileSnapshot(snapshotFile);
});
});

0 comments on commit 6abe20d

Please sign in to comment.