Skip to content

Commit 482ae85

Browse files
committed
add first test for helpers file
1 parent 3de5b66 commit 482ae85

File tree

8 files changed

+358
-39
lines changed

8 files changed

+358
-39
lines changed

.circleci/config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ jobs:
55
- image: circleci/node:latest
66
steps:
77
- checkout
8-
# TODO
8+
- run: npm install
9+
- run: npm run test:unit
910

1011
release:
1112
docker:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ If yes was it frustrating ?
88
If yes then this lib is here to help your user never feel that again. Even if you reload the page or share the link with others user.
99

1010

11-
Now there is already some other lib even in pure Vanilla to sync the query parameters with a javascript object. But you have to rewrite all the logic avec the datatble options (page, pageSize, ordering) and even compare the difference between two state.
11+
Now there is already some other lib even in pure Vanilla to sync the query parameters with a javascript object. But you have to rewrite all the logic with the datatable options (page, pageSize, ordering) and even compare the difference between two state.
1212

1313
By separating the filters and the datable options vue-datatable-url-sync automatise all the desired behavior for working with datatable.
1414

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',
33
transform: {
4-
'^.+\\.vue$': 'vue-jest'
4+
'^.+\\.vue$': 'vue-jest',
55
}
66
}

package-lock.json

+198-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"rollup-plugin-terser": "^7.0.2",
5252
"rollup-plugin-typescript2": "^0.30.0",
5353
"rollup-plugin-vue": "^6.0.0",
54+
"ts-jest": "^26.5.4",
5455
"typescript": "~3.9.3",
5556
"vue": "^3.0.0",
5657
"vue-jest": "^5.0.0-0"

src/utils/helpers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import {VuetifySortArraysObject} from "./VDUSTypes";
22

33
export const elementToArrayOfInt = (element: any): Array<number> => {
44
return ["number", "string"].includes(typeof element)
5-
? [parseInt(element)]
6-
: element.map((item: any) => parseInt(item));
5+
? [extractIntegerValue(element)]
6+
: element.map((item: any) => extractIntegerValue(item));
77
};
88

99
export const elementToArrayOfString = (element: any): Array<string> => {
1010
return element ? (typeof element === "string" ? [element] : element) : [];
1111
};
1212

13-
export const extractBooleanValue = (value: any, defaultValue = true): boolean => {
13+
export const extractBooleanValue = (value: any, defaultValue:boolean|null = true): boolean|null => {
1414
return value ? value.toString() === "true" : defaultValue;
1515
};
1616

@@ -19,7 +19,7 @@ export const extractIntegerValue = (value: any, defaultValue = 0): number => {
1919
return isNaN(parsed) ? defaultValue : parsed;
2020
};
2121

22-
export const getSortsArrayFromOrdering = (ordering: Array<string>): VuetifySortArraysObject => {
22+
export const getSortsArrayFromOrdering = (ordering: Array<string>|null): VuetifySortArraysObject => {
2323
if (!ordering) {
2424
return { sortBy: [], sortDesc: [] };
2525
}

tests/unit/example.spec.ts

-12
This file was deleted.

0 commit comments

Comments
 (0)