diff --git a/src/components/include/include.test.ts b/src/components/include/include.test.ts new file mode 100644 index 000000000..cd91d8ec7 --- /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; + }); +});