From 0df811fe865ffffb6a9ebafe75e0456a72e76fdb Mon Sep 17 00:00:00 2001 From: Zephraph Date: Tue, 23 Apr 2019 20:21:48 -0400 Subject: [PATCH] Add a no-shadow-dom acceptance test --- test/custom-elements/index.js | 2 +- .../samples/no-shadow-dom/_config.js | 4 ++++ .../samples/no-shadow-dom/main.svelte | 9 +++++++++ .../samples/no-shadow-dom/test.js | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/custom-elements/samples/no-shadow-dom/_config.js create mode 100644 test/custom-elements/samples/no-shadow-dom/main.svelte create mode 100644 test/custom-elements/samples/no-shadow-dom/test.js diff --git a/test/custom-elements/index.js b/test/custom-elements/index.js index 32e95266ec..304de2f7eb 100644 --- a/test/custom-elements/index.js +++ b/test/custom-elements/index.js @@ -81,7 +81,7 @@ describe('custom-elements', function() { if (id.endsWith('.svelte')) { const compiled = svelte.compile(code, { customElement: true, - dev: config.dev + ...config }); return compiled.js; diff --git a/test/custom-elements/samples/no-shadow-dom/_config.js b/test/custom-elements/samples/no-shadow-dom/_config.js new file mode 100644 index 0000000000..ad44e196d7 --- /dev/null +++ b/test/custom-elements/samples/no-shadow-dom/_config.js @@ -0,0 +1,4 @@ +export default { + customElement: true, + shadowDom: false +}; \ No newline at end of file diff --git a/test/custom-elements/samples/no-shadow-dom/main.svelte b/test/custom-elements/samples/no-shadow-dom/main.svelte new file mode 100644 index 0000000000..dd5d2d515f --- /dev/null +++ b/test/custom-elements/samples/no-shadow-dom/main.svelte @@ -0,0 +1,9 @@ + + +

Hello world!

+ + diff --git a/test/custom-elements/samples/no-shadow-dom/test.js b/test/custom-elements/samples/no-shadow-dom/test.js new file mode 100644 index 0000000000..2d6a6de09b --- /dev/null +++ b/test/custom-elements/samples/no-shadow-dom/test.js @@ -0,0 +1,17 @@ +import * as assert from 'assert'; +import CustomElement from './main.svelte'; + +export default function (target) { + new CustomElement({ + target + }); + + assert.equal(target.innerHTML, '

Hello world!

'); + + const el = target.querySelector('custom-element'); + const h1 = el.querySelector('h1'); + const { color } = getComputedStyle(h1); + + assert.equal(h1.textContent, 'Hello world!'); + assert.equal(color, 'rgb(0, 0, 255)'); +} \ No newline at end of file