mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 12:09:26 +00:00
update dependencies, cleanup, refine (#642)
* update dependencies, cleanup, refine fixes #637 * update CI command to verify
This commit is contained in:
@@ -4,11 +4,37 @@ import sinon from 'sinon';
|
||||
import '../../../dist/shoelace.js';
|
||||
import type SlInclude from './include';
|
||||
|
||||
const stubbedFetchResponse: Response = {
|
||||
headers: new Headers(),
|
||||
ok: true,
|
||||
redirected: false,
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
type: 'default',
|
||||
url: '',
|
||||
json: () => Promise.resolve({}),
|
||||
text: () => Promise.resolve(''),
|
||||
blob: sinon.fake(),
|
||||
arrayBuffer: sinon.fake(),
|
||||
formData: sinon.fake(),
|
||||
bodyUsed: false,
|
||||
body: null,
|
||||
clone: sinon.fake()
|
||||
};
|
||||
|
||||
describe('<sl-include>', () => {
|
||||
afterEach(() => {
|
||||
sinon.verifyAndRestore();
|
||||
});
|
||||
|
||||
it('should load content and emit sl-load', async () => {
|
||||
const el = await fixture<SlInclude>(
|
||||
html` <sl-include src="https://jsonplaceholder.typicode.com/posts/1"></sl-include> `
|
||||
);
|
||||
sinon.stub(window, 'fetch').resolves({
|
||||
...stubbedFetchResponse,
|
||||
ok: true,
|
||||
status: 200,
|
||||
text: () => Promise.resolve('"id": 1')
|
||||
});
|
||||
const el = await fixture<SlInclude>(html` <sl-include src="/found"></sl-include> `);
|
||||
const loadHandler = sinon.spy();
|
||||
|
||||
el.addEventListener('sl-load', loadHandler);
|
||||
@@ -19,9 +45,13 @@ describe('<sl-include>', () => {
|
||||
});
|
||||
|
||||
it('should emit sl-error when content cannot be loaded', async () => {
|
||||
const el = await fixture<SlInclude>(
|
||||
html` <sl-include src="https://jsonplaceholder.typicode.com/not-found"></sl-include> `
|
||||
);
|
||||
sinon.stub(window, 'fetch').resolves({
|
||||
...stubbedFetchResponse,
|
||||
ok: false,
|
||||
status: 404,
|
||||
text: () => Promise.resolve('{}')
|
||||
});
|
||||
const el = await fixture<SlInclude>(html` <sl-include src="/not-found"></sl-include> `);
|
||||
const loadHandler = sinon.spy();
|
||||
|
||||
el.addEventListener('sl-error', loadHandler);
|
||||
|
||||
Reference in New Issue
Block a user