From 8be9968e40b4123f003ade7be4ee82c8355aeee5 Mon Sep 17 00:00:00 2001 From: Christopher Mardell Date: Mon, 13 Jul 2020 21:10:24 +0930 Subject: [PATCH] Fix props-after-create test --- .../samples/props-after-create/test.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/custom-elements/samples/props-after-create/test.js b/test/custom-elements/samples/props-after-create/test.js index a9e08c168e..c90ccf68b0 100644 --- a/test/custom-elements/samples/props-after-create/test.js +++ b/test/custom-elements/samples/props-after-create/test.js @@ -2,17 +2,22 @@ import * as assert from 'assert'; import CustomElement from './main.svelte'; export default async function (target) { + + // initialize without options to simulate instantiation within HTML const el = new CustomElement(); assert.equal(el.outerHTML, ''); - // const el = target.querySelector('custom-element'); + el.items = ['a', 'b', 'c']; + const p0 = el.shadowRoot.querySelector('p'); - assert.equal(el.shadowRoot, undefined); + // shouldn't be instantitated yet + assert.equal(p0, undefined); - el.items = ['a', 'b', 'c']; - const [p1, p2] = el.shadowRoot.querySelectorAll('p'); + // simulate adding to DOM to trigger setup + el.connectedCallback(); + const [p1, p2] = el.shadowRoot.querySelectorAll('p'); assert.equal(p1.textContent, '3 items'); assert.equal(p2.textContent, 'a, b, c');