summaryrefslogtreecommitdiff
path: root/test/astro-styles-ssr.test.js
diff options
context:
space:
mode:
authorGravatar Drew Powers <1369770+drwpow@users.noreply.github.com> 2021-04-02 10:16:16 -0600
committerGravatar GitHub <noreply@github.com> 2021-04-02 10:16:16 -0600
commit003b3c395f81df26010112928a30c2d88f283b53 (patch)
tree6dd9057a0758eb1030018062a72126a8efb9f098 /test/astro-styles-ssr.test.js
parent2646f800af80703ae6498232d270a4637fe56dca (diff)
downloadastro-003b3c395f81df26010112928a30c2d88f283b53.tar.gz
astro-003b3c395f81df26010112928a30c2d88f283b53.tar.zst
astro-003b3c395f81df26010112928a30c2d88f283b53.zip
Get CSS Modules working in Vue (#53)
Diffstat (limited to 'test/astro-styles-ssr.test.js')
-rw-r--r--test/astro-styles-ssr.test.js36
1 files changed, 30 insertions, 6 deletions
diff --git a/test/astro-styles-ssr.test.js b/test/astro-styles-ssr.test.js
index 2342fcda4..8293e4996 100644
--- a/test/astro-styles-ssr.test.js
+++ b/test/astro-styles-ssr.test.js
@@ -34,7 +34,13 @@ StylesSSR.after(async () => {
});
StylesSSR('Has <link> tags', async () => {
- const MUST_HAVE_LINK_TAGS = ['/_astro/components/SvelteScoped.svelte.css', '/_astro/components/VueCSS.vue.css', '/_astro/components/ReactCSS.css'];
+ const MUST_HAVE_LINK_TAGS = [
+ '/_astro/components/ReactCSS.css',
+ '/_astro/components/SvelteScoped.svelte.css',
+ '/_astro/components/VueCSS.vue.css',
+ '/_astro/components/VueModules.vue.css',
+ '/_astro/components/VueScoped.vue.css',
+ ];
const result = await runtime.load('/');
const $ = doc(result.contents);
@@ -46,14 +52,32 @@ StylesSSR('Has <link> tags', async () => {
});
StylesSSR('Has correct CSS classes', async () => {
- const MUST_HAVE_CSS_CLASSES = ['react-title', 'vue-title', 'svelte-title'];
-
const result = await runtime.load('/');
const $ = doc(result.contents);
- for (const className of MUST_HAVE_CSS_CLASSES) {
- const el = $(`.${className}`);
- assert.equal(el.length, 1);
+ const MUST_HAVE_CLASSES = {
+ '#react-css': 'react-title',
+ '#vue-css': 'vue-title',
+ '#vue-css-modules': '_title_1gi0u_2', // ⚠️ may be flaky
+ '#vue-scoped': 'vue-title', // also has data-v-* property
+ '#svelte-scoped': 'svelte-title', // also has additional class
+ };
+
+ for (const [selector, className] of Object.entries(MUST_HAVE_CLASSES)) {
+ const el = $(selector);
+ assert.ok(el.attr('class').includes(className));
+
+ // add’l test: Vue Scoped styles should have data-v-* attribute
+ if (selector === '#vue-scoped') {
+ const { attribs } = el.get(0);
+ const scopeId = Object.keys(attribs).find((k) => k.startsWith('data-v-'));
+ assert.ok(scopeId);
+ }
+
+ // add’l test: Svelte should have another class
+ if (selector === '#svelte-title') {
+ assert.not.equal(el.attr('class'), className);
+ }
}
});