mirror of
https://github.com/iconify/iconify.git
synced 2025-01-22 22:58:27 +00:00
Migrate Svelte component to Vitest, update dependencies
This commit is contained in:
parent
62503242d0
commit
d744890b3f
@ -3,13 +3,14 @@ module.exports = {
|
|||||||
verbose: true,
|
verbose: true,
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.svelte$': 'svelte-jester',
|
'^.+\\.svelte$': 'svelte-jester',
|
||||||
|
'^.+\\.ts$': [
|
||||||
|
'ts-jest',
|
||||||
|
{
|
||||||
|
tsconfig: 'tests/tsconfig.json',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
preset: 'ts-jest',
|
preset: 'ts-jest',
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
testMatch: ['**/tests/**/*.test.ts'],
|
testMatch: ['**/tests/**/*.test.ts'],
|
||||||
globals: {
|
|
||||||
'ts-jest': {
|
|
||||||
tsconfig: 'tests/tsconfig.json',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"build:tsc": "tsc -b",
|
"build:tsc": "tsc -b",
|
||||||
"build:bundles": "rollup -c rollup.config.js",
|
"build:bundles": "rollup -c rollup.config.js",
|
||||||
"build:api": "node build --only-api",
|
"build:api": "node build --only-api",
|
||||||
"test": "jest --runInBand"
|
"test": "vitest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iconify/types": "workspace:^"
|
"@iconify/types": "workspace:^"
|
||||||
@ -31,22 +31,21 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@iconify/core": "workspace:^",
|
"@iconify/core": "workspace:^",
|
||||||
"@iconify/utils": "workspace:^",
|
"@iconify/utils": "workspace:^",
|
||||||
"@microsoft/api-extractor": "^7.25.2",
|
"@microsoft/api-extractor": "^7.30.0",
|
||||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
"@rollup/plugin-node-resolve": "^14.0.0",
|
||||||
"@rollup/plugin-typescript": "^8.3.3",
|
"@rollup/plugin-typescript": "^8.5.0",
|
||||||
"@testing-library/jest-dom": "^5.16.4",
|
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.49",
|
||||||
"@testing-library/svelte": "^3.1.3",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
|
"@testing-library/svelte": "^3.2.1",
|
||||||
"@tsconfig/svelte": "^3.0.0",
|
"@tsconfig/svelte": "^3.0.0",
|
||||||
"@types/jest": "^27.5.2",
|
"@types/jest": "^29.0.0",
|
||||||
"jest": "^28.1.1",
|
"@types/node": "^18.7.15",
|
||||||
"jest-environment-jsdom": "^28.1.1",
|
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rollup": "^2.75.6",
|
"rollup": "^2.79.0",
|
||||||
"rollup-plugin-svelte": "^7.1.0",
|
"rollup-plugin-svelte": "^7.1.0",
|
||||||
"svelte": "3.39",
|
"svelte": "3.50.0",
|
||||||
"svelte-jester": "^2.3.2",
|
|
||||||
"svelte-preprocess": "^4.10.7",
|
"svelte-preprocess": "^4.10.7",
|
||||||
"ts-jest": "28.0.0-next.3"
|
"vitest": "^0.23.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"svelte": ">=3"
|
"svelte": ">=3"
|
||||||
|
@ -143,7 +143,7 @@ describe('Rendering icon', () => {
|
|||||||
|
|
||||||
// Should render empty icon
|
// Should render empty icon
|
||||||
const html = component.container.innerHTML;
|
const html = component.container.innerHTML;
|
||||||
expect(html).toBe('<div></div>');
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe('<div></div>');
|
||||||
|
|
||||||
// onLoad should not have been called yet
|
// onLoad should not have been called yet
|
||||||
expect(onLoadCalled).toBe(false);
|
expect(onLoadCalled).toBe(false);
|
||||||
@ -173,17 +173,23 @@ describe('Rendering icon', () => {
|
|||||||
tick()
|
tick()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const html = component.container.innerHTML;
|
const html = component.container.innerHTML;
|
||||||
expect(html).toBe('<div></div>');
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe(
|
||||||
|
'<div></div>'
|
||||||
|
);
|
||||||
return tick();
|
return tick();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const html = component.container.innerHTML;
|
const html = component.container.innerHTML;
|
||||||
expect(html).toBe('<div></div>');
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe(
|
||||||
|
'<div></div>'
|
||||||
|
);
|
||||||
return tick();
|
return tick();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const html = component.container.innerHTML;
|
const html = component.container.innerHTML;
|
||||||
expect(html).toBe('<div></div>');
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe(
|
||||||
|
'<div></div>'
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(done);
|
.catch(done);
|
||||||
@ -203,6 +209,6 @@ describe('Rendering icon', () => {
|
|||||||
|
|
||||||
// Should render empty icon
|
// Should render empty icon
|
||||||
const html = component.container.innerHTML;
|
const html = component.container.innerHTML;
|
||||||
expect(html).toBe('<div></div>');
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe('<div></div>');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -158,7 +158,7 @@ describe('Rendering icon', () => {
|
|||||||
|
|
||||||
// Should render empty icon
|
// Should render empty icon
|
||||||
const html = component.container.innerHTML;
|
const html = component.container.innerHTML;
|
||||||
expect(html).toBe('<div></div>');
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe('<div></div>');
|
||||||
|
|
||||||
// onLoad should not have been called yet
|
// onLoad should not have been called yet
|
||||||
expect(onLoadCalled).toBe('');
|
expect(onLoadCalled).toBe('');
|
||||||
@ -259,7 +259,7 @@ describe('Rendering icon', () => {
|
|||||||
|
|
||||||
// Should render empty icon
|
// Should render empty icon
|
||||||
const html = component.container.innerHTML;
|
const html = component.container.innerHTML;
|
||||||
expect(html).toBe('<div></div>');
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe('<div></div>');
|
||||||
|
|
||||||
// Fixture callback should have been called
|
// Fixture callback should have been called
|
||||||
expect(typeof triggerSwap).toBe('function');
|
expect(typeof triggerSwap).toBe('function');
|
||||||
@ -363,7 +363,7 @@ describe('Rendering icon', () => {
|
|||||||
|
|
||||||
// Should render empty icon
|
// Should render empty icon
|
||||||
const html = component.container.innerHTML;
|
const html = component.container.innerHTML;
|
||||||
expect(html).toBe('<div></div>');
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe('<div></div>');
|
||||||
|
|
||||||
// onLoad should not have been called yet
|
// onLoad should not have been called yet
|
||||||
expect(onLoadCalled).toBe(false);
|
expect(onLoadCalled).toBe(false);
|
||||||
|
@ -25,7 +25,7 @@ describe('Creating component', () => {
|
|||||||
const html = (node.parentNode as HTMLDivElement).innerHTML;
|
const html = (node.parentNode as HTMLDivElement).innerHTML;
|
||||||
|
|
||||||
// Check HTML
|
// Check HTML
|
||||||
expect(html).toBe(
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe(
|
||||||
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" viewBox="0 0 24 24"><path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"></path></svg>'
|
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" viewBox="0 0 24 24"><path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"></path></svg>'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -10,6 +10,6 @@ describe('Empty icon', () => {
|
|||||||
const html = component.container.innerHTML;
|
const html = component.container.innerHTML;
|
||||||
|
|
||||||
// Empty container div
|
// Empty container div
|
||||||
expect(html).toBe('<div></div>');
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe('<div></div>');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ describe('Creating component', () => {
|
|||||||
const html = (node.parentNode as HTMLDivElement).innerHTML;
|
const html = (node.parentNode as HTMLDivElement).innerHTML;
|
||||||
|
|
||||||
// Check HTML
|
// Check HTML
|
||||||
expect(html).toBe(
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe(
|
||||||
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" viewBox="0 0 24 24"><path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"></path></svg>'
|
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" viewBox="0 0 24 24"><path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"></path></svg>'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
11
components/svelte/vitest.config.mjs
Normal file
11
components/svelte/vitest.config.mjs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { defineConfig } from 'vitest/config';
|
||||||
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [svelte()],
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
watch: false,
|
||||||
|
include: ['**/tests/**/*.test.ts'],
|
||||||
|
},
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user