Setup tests

This commit is contained in:
Vadim
2021-01-27 21:17:27 +03:00
parent dd0e5208ea
commit 0a217f326b
5 changed files with 1532 additions and 58 deletions

15
.babelrc Normal file
View File

@@ -0,0 +1,15 @@
{
"presets": [
["@babel/preset-env", {
"modules": false,
"targets": {
"browsers": "ie >= 11"
}
}]
],
"env": {
"test": {
"presets": [["@babel/preset-env"]]
}
}
}

View File

@@ -28,10 +28,12 @@
"build-storybook": "build-storybook", "build-storybook": "build-storybook",
"build:docs": "set DOCS=true && rollup -c", "build:docs": "set DOCS=true && rollup -c",
"dev:docs": "set DOCS=true && rollup -c -w", "dev:docs": "set DOCS=true && rollup -c -w",
"test": "jest",
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.10", "@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@rollup/plugin-commonjs": "^17.0.0", "@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-json": "^4.1.0", "@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.0.0", "@rollup/plugin-node-resolve": "^11.0.0",
@@ -40,9 +42,11 @@
"@storybook/addon-links": "^6.1.14", "@storybook/addon-links": "^6.1.14",
"@storybook/svelte": "^6.1.14", "@storybook/svelte": "^6.1.14",
"babel-loader": "^8.2.2", "babel-loader": "^8.2.2",
"jest": "^26.6.3",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"mdsvex": "^0.8.9", "mdsvex": "^0.8.9",
"rollup": "^2.3.4", "rollup": "^2.3.4",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-css-only": "^3.1.0", "rollup-plugin-css-only": "^3.1.0",
"rollup-plugin-livereload": "^2.0.0", "rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.0.0", "rollup-plugin-svelte": "^7.0.0",

View File

@@ -5,6 +5,7 @@ import resolve from '@rollup/plugin-node-resolve';
import json from '@rollup/plugin-json'; import json from '@rollup/plugin-json';
import livereload from 'rollup-plugin-livereload'; import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser'; import { terser } from 'rollup-plugin-terser';
import babel from 'rollup-plugin-babel';
import css from 'rollup-plugin-css-only'; import css from 'rollup-plugin-css-only';
import { mdsvex } from "mdsvex"; import { mdsvex } from "mdsvex";
@@ -97,6 +98,10 @@ export default {
production && terser(), production && terser(),
json(), json(),
babel({
exclude: 'node_modules/**',
})
], ],
watch: { watch: {
clearScreen: false clearScreen: false

View File

@@ -1,10 +1,10 @@
export function getNextPageIndexLimited(currentPageIndex, pagesCount) { export function getNextPageIndexLimited(currentPageIndex, pagesCount) {
return Math.min(currentPageIndex + 1, pagesCount - 1) return Math.min(Math.max(currentPageIndex + 1, 0), pagesCount - 1)
} }
export function getNextPageIndexInfinte(currentPageIndex, pagesCount) { export function getNextPageIndexInfinte(currentPageIndex, pagesCount) {
const newCurrentPageIndex = currentPageIndex + 1 const newCurrentPageIndex = Math.max(currentPageIndex, 0) + 1
return newCurrentPageIndex > pagesCount - 1 ? 0 : newCurrentPageIndex return newCurrentPageIndex > pagesCount - 1 ? 0 : Math.max(newCurrentPageIndex, 0)
} }
export function getNextPageIndexFn(infinite) { export function getNextPageIndexFn(infinite) {
@@ -12,12 +12,12 @@ export function getNextPageIndexFn(infinite) {
} }
export function getPrevPageIndexLimited(currentPageIndex, pagesCount) { export function getPrevPageIndexLimited(currentPageIndex, pagesCount) {
return Math.max(currentPageIndex - 1, 0) return Math.max(Math.min(currentPageIndex - 1, pagesCount - 1), 0)
} }
export function getPrevPageIndexInfinte(currentPageIndex, pagesCount) { export function getPrevPageIndexInfinte(currentPageIndex, pagesCount) {
const newCurrentPageIndex = currentPageIndex - 1 const newCurrentPageIndex = Math.min(currentPageIndex, pagesCount - 1) - 1
return newCurrentPageIndex >= 0 ? newCurrentPageIndex : pagesCount - 1 return newCurrentPageIndex >= 0 ? Math.min(newCurrentPageIndex, pagesCount - 1) : pagesCount - 1
} }
export function getPrevPageIndexFn(infinite) { export function getPrevPageIndexFn(infinite) {

1554
yarn.lock

File diff suppressed because it is too large Load Diff