mirror of
https://github.com/JasonHHouse/gaps.git
synced 2025-12-20 02:01:52 -06:00
Adding jest to common
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -53,3 +53,5 @@ GapsAsJar/*
|
||||
!GapsAsJar/start.bat
|
||||
!GapsAsJar/gaps.nsi
|
||||
.DS_Store
|
||||
|
||||
coverage/
|
||||
|
||||
@@ -18,6 +18,21 @@ export function getContextPath(url) {
|
||||
return url;
|
||||
}
|
||||
|
||||
export function getYear(year) {
|
||||
if ((year && year !== -1) && (year && year !== 0)) {
|
||||
return ` (${year})`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
export function isEqual(a, b) {
|
||||
return a === b;
|
||||
}
|
||||
|
||||
export function isNotOwned(value) {
|
||||
return !value;
|
||||
}
|
||||
|
||||
export async function getOwnedMoviesForTable(url, movieContainer, noMovieContainer, moviesTable) {
|
||||
const response = await fetch(getContextPath(url), {
|
||||
method: 'get',
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
/* global Handlebars, SockJS, Stomp */
|
||||
/* eslint no-undef: "error" */
|
||||
|
||||
import { getContextPath, getRecommendedMoviesForTable } from '../modules/common.min.js';
|
||||
import { getContextPath, getRecommendedMoviesForTable, getYear, isEqual, isNotOwned } from '../modules/common.min.js';
|
||||
import Payload from '../modules/payload.min.js';
|
||||
|
||||
let libraryTitle;
|
||||
@@ -118,18 +118,9 @@ function copyToClipboard() {
|
||||
|
||||
jQuery(($) => {
|
||||
Handlebars.registerHelper({
|
||||
isNotOwned(value) {
|
||||
return !value;
|
||||
},
|
||||
isEqual(a, b) {
|
||||
return a === b;
|
||||
},
|
||||
getYear(year) {
|
||||
if (year && (year !== -1 || year !== 0)) {
|
||||
return ` (${year})`;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
isNotOwned,
|
||||
isEqual,
|
||||
getYear,
|
||||
});
|
||||
|
||||
libraryTitle = $('#libraryTitle');
|
||||
|
||||
33
GapsWeb/src/test/resources/static/js/page/common.test.js
Normal file
33
GapsWeb/src/test/resources/static/js/page/common.test.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { getYear, isEqual, isNotOwned } from '../../../../../main/resources/static/js/modules/common';
|
||||
|
||||
test('Checks for valid year', () => {
|
||||
expect(getYear(2005)).toBe(' (2005)');
|
||||
});
|
||||
|
||||
test('Checks for year 0', () => {
|
||||
expect(getYear(0)).toBe('');
|
||||
});
|
||||
|
||||
test('Checks for year -1', () => {
|
||||
expect(getYear(-1)).toBe('');
|
||||
});
|
||||
|
||||
test('Checks for no year', () => {
|
||||
expect(getYear()).toBe('');
|
||||
});
|
||||
|
||||
test('Two equal TMDB IDs', () => {
|
||||
expect(isEqual(1234567,1234567)).toBe(true);
|
||||
});
|
||||
|
||||
test('Two unequal TMDB IDs', () => {
|
||||
expect(isEqual(1234567,7654321)).toBe(false);
|
||||
});
|
||||
|
||||
test('Should be owned', () => {
|
||||
expect(isNotOwned(true)).toBe(false);
|
||||
});
|
||||
|
||||
test('Should not be owned', () => {
|
||||
expect(isNotOwned(false)).toBe(true);
|
||||
});
|
||||
1
build
1
build
@@ -16,6 +16,7 @@ JAR_VERSION="GapsWeb/target/GapsWeb-$VERSION.jar"
|
||||
ZIP_VERSION="GapsAsJar-$VERSION.zip"
|
||||
npm ci
|
||||
./minify
|
||||
npm run test
|
||||
mvn clean install
|
||||
docker buildx build --platform linux/s390x,linux/amd64 -t housewrecker/gaps:latest -f Dockerfile --push .
|
||||
#docker buildx build --platform linux/riscv64 -t housewrecker/gaps:risc-latest -f Dockerfile.riscv64 --push .
|
||||
|
||||
12
jest.config.json
Normal file
12
jest.config.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"collectCoverage": true,
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"mjs"
|
||||
],
|
||||
"transform": {
|
||||
"^.+\\.js$": "babel-jest",
|
||||
"^.+\\.mjs$": "babel-jest"
|
||||
},
|
||||
"testRegex": "((\\.|/*.)(test))\\.js?$"
|
||||
}
|
||||
4710
package-lock.json
generated
4710
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -12,10 +12,14 @@
|
||||
"uglifyjs-folder": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/node": "^7.14.2",
|
||||
"@babel/preset-env": "^7.14.4",
|
||||
"cypress": "^7.4.0",
|
||||
"eslint": "^7.10.0",
|
||||
"eslint-config-airbnb-base": "^14.2.0",
|
||||
"eslint-plugin-import": "^2.22.1"
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"jest": "^27.0.3"
|
||||
},
|
||||
"scripts": {
|
||||
"e2e": "cypress open",
|
||||
@@ -23,7 +27,8 @@
|
||||
"uglifyjs-modules": "rm -f GapsWeb/src/main/resources/static/js/modules/*.min.js && uglifyjs-folder GapsWeb/src/main/resources/static/js/modules/ -eo GapsWeb/src/main/resources/static/js/modules/\n",
|
||||
"uglifyjs-pages": "rm -f GapsWeb/src/main/resources/static/js/page/*.min.js && uglifyjs-folder GapsWeb/src/main/resources/static/js/page/ -eo GapsWeb/src/main/resources/static/js/page/\n",
|
||||
"eslint-cypress": "./node_modules/.bin/eslint --fix cypress/integration",
|
||||
"eslint-gaps": "./node_modules/.bin/eslint --fix GapsWeb/src/main/resources/static/js"
|
||||
"eslint-gaps": "./node_modules/.bin/eslint --fix GapsWeb/src/main/resources/static/js",
|
||||
"test": "jest --verbose GapsWeb/src/test/resources/static/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user