From 3b2b5eed5aa015daa7ebf6c9ca15e15ab82bea79 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Tue, 15 Jun 2021 09:11:04 -0400 Subject: [PATCH] add test for sl-include --- src/components/include/include.test.ts | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/components/include/include.test.ts diff --git a/src/components/include/include.test.ts b/src/components/include/include.test.ts new file mode 100644 index 00000000..cd91d8ec --- /dev/null +++ b/src/components/include/include.test.ts @@ -0,0 +1,28 @@ +import { expect, fixture, html, waitUntil } from '@open-wc/testing'; +import sinon from 'sinon'; + +import '../../../dist/shoelace.js'; +import type SlInclude from './include'; + +describe('', () => { + it('should load content and emit sl-load', async () => { + const el = await fixture(html` `); + const loadHandler = sinon.spy(); + + el.addEventListener('sl-load', loadHandler); + await waitUntil(() => loadHandler.calledOnce); + + expect(el.innerHTML).to.contain('"id": 1'); + expect(loadHandler).to.have.been.calledOnce; + }); + + it('should emit sl-error when content cannot be loaded', async () => { + const el = await fixture(html` `); + const loadHandler = sinon.spy(); + + el.addEventListener('sl-error', loadHandler); + await waitUntil(() => loadHandler.calledOnce); + + expect(loadHandler).to.have.been.calledOnce; + }); +});