diff --git a/jest-setup.js b/jest-setup.js new file mode 100644 index 000000000..d0de870dc --- /dev/null +++ b/jest-setup.js @@ -0,0 +1 @@ +import "@testing-library/jest-dom"; diff --git a/jest.config.js b/jest.config.js index 5dae9db74..f319f3cd2 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,13 +6,15 @@ export default { }, moduleFileExtensions: ["js", "ts", "svelte"], rootDir: "src", - setupFiles: ["dotenv/config"], + setupFiles: ["dotenv/config", "/langs/i18n.js"], + setupFilesAfterEnv: ["/../jest-setup.js"], testEnvironment: "jsdom", transform: { "^.+\\.svelte$": ["svelte-jester", { preprocess: true }], - "^.+\\.ts$": ["ts-jest", { useESM: true }], + "^.+\\.ts$": ["ts-jest", { useESM: true, tsconfig: "tsconfig.test.json" }], }, transformIgnorePatterns: ["/node_modules/(?!svue).+\\.js$"], + coverageDirectory: "/../coverage", collectCoverageFrom: ["./**/*.{js,ts,svelte}"], - coverageReporters: ["html", "text-summary"], + coverageReporters: ["lcov", "html", "text-summary"], }; diff --git a/package-lock.json b/package-lock.json index c9c55e068..1fb28a03b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,10 +70,12 @@ "@storybook/svelte": "^7.6.10", "@storybook/svelte-webpack5": "^7.6.10", "@storybook/testing-library": "^0.2.2", + "@testing-library/jest-dom": "^6.4.2", + "@testing-library/svelte": "^4.1.0", "@types/lucene": "^2.1.7", "chromatic": "^9.1.0", "eslint": "^7.32.0", - "jest": "^29.6.3", + "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "msw": "^1.2.3", "msw-storybook-addon": "^1.10.0", @@ -6571,17 +6573,17 @@ } }, "node_modules/@testing-library/jest-dom": { - "version": "6.1.5", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.1.5.tgz", - "integrity": "sha512-3y04JLW+EceVPy2Em3VwNr95dOKqA8DhR0RJHhHKDZNYXcVXnEK7WIrpj4eYU8SVt/qYZ2aRWt/WgQ+grNES8g==", + "version": "6.4.2", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.4.2.tgz", + "integrity": "sha512-CzqH0AFymEMG48CpzXFriYYkOjk6ZGPCLMhW9e9jg3KMCn5OfJecF8GtGW7yGfR/IgCe3SX8BSwjdzI6BBbZLw==", "dev": true, "dependencies": { - "@adobe/css-tools": "^4.3.1", + "@adobe/css-tools": "^4.3.2", "@babel/runtime": "^7.9.2", "aria-query": "^5.0.0", "chalk": "^3.0.0", "css.escape": "^1.5.1", - "dom-accessibility-api": "^0.5.6", + "dom-accessibility-api": "^0.6.3", "lodash": "^4.17.15", "redent": "^3.0.0" }, @@ -6592,6 +6594,7 @@ }, "peerDependencies": { "@jest/globals": ">= 28", + "@types/bun": "latest", "@types/jest": ">= 28", "jest": ">= 28", "vitest": ">= 0.32" @@ -6600,6 +6603,9 @@ "@jest/globals": { "optional": true }, + "@types/bun": { + "optional": true + }, "@types/jest": { "optional": true }, @@ -6639,6 +6645,12 @@ "node": ">=8" } }, + "node_modules/@testing-library/jest-dom/node_modules/dom-accessibility-api": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz", + "integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==", + "dev": true + }, "node_modules/@testing-library/jest-dom/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -6660,6 +6672,21 @@ "node": ">=8" } }, + "node_modules/@testing-library/svelte": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@testing-library/svelte/-/svelte-4.1.0.tgz", + "integrity": "sha512-MJqe7x9WowkiAVdk9mvazEC2ktFZdmK2OqFVoO557PC37aBemQ4ozqdK3yrG34Zg9kuln3qgTVeLSh08e69AMw==", + "dev": true, + "dependencies": { + "@testing-library/dom": "^9.3.1" + }, + "engines": { + "node": ">= 10" + }, + "peerDependencies": { + "svelte": "^3 || ^4" + } + }, "node_modules/@testing-library/user-event": { "version": "14.5.1", "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.5.1.tgz", diff --git a/package.json b/package.json index 723824698..ce8edfdec 100644 --- a/package.json +++ b/package.json @@ -65,10 +65,12 @@ "@storybook/svelte": "^7.6.10", "@storybook/svelte-webpack5": "^7.6.10", "@storybook/testing-library": "^0.2.2", + "@testing-library/jest-dom": "^6.4.2", + "@testing-library/svelte": "^4.1.0", "@types/lucene": "^2.1.7", "chromatic": "^9.1.0", "eslint": "^7.32.0", - "jest": "^29.6.3", + "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "msw": "^1.2.3", "msw-storybook-addon": "^1.10.0", diff --git a/src/addons/Paginator.svelte b/src/addons/Paginator.svelte deleted file mode 100644 index ce41c18c7..000000000 --- a/src/addons/Paginator.svelte +++ /dev/null @@ -1,37 +0,0 @@ - - -
- - - -
- - diff --git a/src/addons/browser/Browser.svelte b/src/addons/browser/Browser.svelte index a975fdea8..4bb6408aa 100644 --- a/src/addons/browser/Browser.svelte +++ b/src/addons/browser/Browser.svelte @@ -2,13 +2,14 @@ @@ -117,7 +75,10 @@
diff --git a/src/addons/browser/Categories.svelte b/src/addons/browser/Categories.svelte new file mode 100644 index 000000000..d4d4813e8 --- /dev/null +++ b/src/addons/browser/Categories.svelte @@ -0,0 +1,38 @@ + + +
+

{$_("addonBrowserDialog.categories")}

+
    + {#each CATEGORIES as [category, name]} +
  • + + + +
  • + {/each} +
+
+ + diff --git a/src/addons/browser/Filters.svelte b/src/addons/browser/Filters.svelte index fcef773df..98f066aa0 100644 --- a/src/addons/browser/Filters.svelte +++ b/src/addons/browser/Filters.svelte @@ -1,78 +1,30 @@ - -
    -
  • - - - - -
  • - -
  • - - - - -
  • -
  • - - - - -
  • + {#each FILTERS as [id, name]} +
  • + + + + +
  • + {/each}
-
-

{$_("addonBrowserDialog.categories")}

-
    - {#each CATEGORIES as [category, name]} -
  • - - - -
  • - {/each} -
-
diff --git a/src/addons/browser/SearchInput.svelte b/src/common/SearchInput.svelte similarity index 93% rename from src/addons/browser/SearchInput.svelte rename to src/common/SearchInput.svelte index e580b9ab8..3f655646a 100644 --- a/src/addons/browser/SearchInput.svelte +++ b/src/common/SearchInput.svelte @@ -6,7 +6,7 @@
diff --git a/src/pages/app/EmbedFooter.svelte b/src/pages/app/EmbedFooter.svelte index 92df224bc..66a4ed230 100644 --- a/src/pages/app/EmbedFooter.svelte +++ b/src/pages/app/EmbedFooter.svelte @@ -1,14 +1,22 @@