Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@ module.exports = {
tsconfigRootDir: __dirname,
project: 'tsconfig.eslint.json',
},
settings: {
jest: {
version: 27,
},
},
extends: '@lars-reimann',
};
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Test with Jest
- name: Test with Vitest
run: npm run test-with-coverage

- name: Upload coverage to Codecov
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Test with Jest
- name: Test with Vitest
run: npm run test-with-coverage

- name: Upload coverage to Codecov
Expand Down
3 changes: 1 addition & 2 deletions api-editor/gui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tasks.register<NpmTask>("buildGUI") {
"index.html",
"package.json",
"tsconfig.json",
"vite.config.ts"
"vite.config.ts",
)
outputs.dirs("dist")

Expand All @@ -47,7 +47,6 @@ tasks.register<NpmTask>("testGUI") {

inputs.dir("src")
inputs.files(
"jest.config.json",
"package.json",
"tsconfig.json",
)
Expand Down
6 changes: 0 additions & 6 deletions api-editor/gui/jest.config.json

This file was deleted.

22,524 changes: 8,131 additions & 14,393 deletions api-editor/gui/package-lock.json

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions api-editor/gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dev": "vite",
"build": "tsc && vite build",
"serve": "vite preview",
"test": "jest src",
"test-with-coverage": "jest src --coverage",
"test": "vitest src",
"test-with-coverage": "vitest src --coverage",
"gen:theme-typings": "chakra-cli tokens src/theme/index.ts",
"postinstall": "npm run gen:theme-typings"
},
Expand Down Expand Up @@ -46,9 +46,6 @@
"@chakra-ui/cli": "^2.3.0",
"@hookform/devtools": "^4.3.1",
"@lars-reimann/prettier-config": "^5.0.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@types/jest": "^28.1.6",
"@types/node-fetch": "^2.6.2",
"@types/react": "^18.0.31",
"@types/react-dom": "^18.0.11",
Expand All @@ -57,10 +54,10 @@
"@types/react-window": "^1.8.4",
"@types/uuid": "^9.0.1",
"@vitejs/plugin-react": "^3.1.0",
"jest": "^28.1.3",
"@vitest/coverage-c8": "^0.29.8",
"node-fetch": "^2.6.7",
"ts-jest": "^28.0.7",
"typescript": "^5.0.3",
"vite": "^4.2.1"
"vite": "^4.2.1",
"vitest": "^0.29.8"
}
}
5 changes: 3 additions & 2 deletions api-editor/gui/src/common/util/listOperations.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { groupBy, isEmptyList } from './listOperations';
import { expect, test } from 'vitest';

test('isEmptyList returns true for empty lists', () => {
expect(isEmptyList([])).toBe(true);
expect(isEmptyList([])).toBeTruthy();
});

test('isEmptyLists returns false for non-empty lists', () => {
expect(isEmptyList([1])).toBe(false);
expect(isEmptyList([1])).toBeFalsy();
});

test('groupBy with empty list', () => {
Expand Down
9 changes: 5 additions & 4 deletions api-editor/gui/src/common/util/stringOperations.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { pluralize, truncate } from './stringOperations';
import { expect, it, describe } from 'vitest';

describe('truncate', () => {
test('should return strings with at most max length unchanged', () => {
it('should return strings with at most max length unchanged', () => {
expect(truncate('Lorem ipsum', 11)).toBe('Lorem ipsum');
});

test('should truncate strings longer than max length and append ...', () => {
it('should truncate strings longer than max length and append ...', () => {
expect(truncate('Lorem ipsum', 10)).toBe('Lorem ips\u2026');
});
});

describe('pluralize', () => {
test('should return singular if count is count', () => {
it('should return singular if count is count', () => {
expect(pluralize(1, 'thing')).toBe('1 thing');
});

test('should return plural otherwise', () => {
it('should return plural otherwise', () => {
expect(pluralize(0, 'thing')).toBe('0 things');
expect(pluralize(2, 'thing')).toBe('2 things');
});
Expand Down
15 changes: 8 additions & 7 deletions api-editor/gui/src/common/util/validation.test.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
import { isValidJsonFile, isValidPythonIdentifier } from './validation';
import { expect, test } from 'vitest';

test('valid name starting with lower case letter', () => {
const testString = 'hallo_welt';
expect(isValidPythonIdentifier(testString)).toBe(true);
expect(isValidPythonIdentifier(testString)).toBeTruthy();
});

test('valid name starting with _', () => {
const testString = '_hallo_welt';
expect(isValidPythonIdentifier(testString)).toBe(true);
expect(isValidPythonIdentifier(testString)).toBeTruthy();
});

test('valid name starting with upper case letter', () => {
const testString = 'Hallo_welt';
expect(isValidPythonIdentifier(testString)).toBe(true);
expect(isValidPythonIdentifier(testString)).toBeTruthy();
});

test('invalid name with %', () => {
const testString = 'Hallo%welt';
expect(isValidPythonIdentifier(testString)).toBe(false);
expect(isValidPythonIdentifier(testString)).toBeFalsy();
});

test('invalid name starting with number', () => {
const testString = '9Hallo_Welt';
expect(isValidPythonIdentifier(testString)).toBe(false);
expect(isValidPythonIdentifier(testString)).toBeFalsy();
});

test('invalid json file name', () => {
const testString = 'helloWorld.png';
expect(isValidJsonFile(testString)).toBe(false);
expect(isValidJsonFile(testString)).toBeFalsy();
});

test('valid json file name', () => {
const testString = 'helloWorld.json';
expect(isValidJsonFile(testString)).toBe(true);
expect(isValidJsonFile(testString)).toBeTruthy();
});
71 changes: 36 additions & 35 deletions api-editor/gui/src/common/validation.test.ts
Original file line number Diff line number Diff line change
@@ -1,176 +1,177 @@
import { numberPattern, booleanPattern, moduleNamePattern } from './validation';
import { expect, test } from 'vitest';

test('valid natural number', () => {
const testNumber = '1';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('valid negative integer', () => {
const testNumber = '-1234567890';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('valid negative decimal number', () => {
const testNumber = '-1234567890.0';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('invalid negative decimal number with ending "."', () => {
const testNumber = '-1234567890.';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('zero is a valid decimal number', () => {
const testNumber = '0';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('number with leading "+" is not a valid decimal number', () => {
const testNumber = '+1234567890.1234567890';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('number with leading 0 is not a valid number', () => {
const testNumber = '015';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('negative number with empty integer part is a valid number', () => {
const testNumber = '-.2';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('positive number with empty integer part is a valid number', () => {
const testNumber = '.01';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('empty negative decimal number is not a valid number', () => {
const testNumber = '-.';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('number with "-" sign in the middle is not a valid number', () => {
const testNumber = '15-67';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('number with "+" sign in the middle is not a valid number', () => {
const testNumber = '15+67';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('letter is not a valid number', () => {
const testNumber = 'a';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('number containing a letter is not a valid number', () => {
const testNumber = '12345a';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('valid integer with exponent', () => {
const testNumber = '12e3';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('valid integer with exponent "+"', () => {
const testNumber = '12e+3';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('valid number with exponent and "-"', () => {
const testNumber = '12.1e-3';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('valid negative number with negative exponent', () => {
const testNumber = '-0.12E-3';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('valid negative number with empty integer part and negative exponent', () => {
const testNumber = '-.12E-3';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(true);
expect(Boolean(testNumber.match(numberPattern.value))).toBeTruthy();
});

test('invalid number containing two "e"', () => {
const testNumber = '1e2e3';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('invalid number only containing exponent', () => {
const testNumber = 'e3';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('invalid number containing only "E"', () => {
const testNumber = 'E';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('invalid number containing two exponents', () => {
const testNumber = '1E5e3';
expect(Boolean(testNumber.match(numberPattern.value))).toBe(false);
expect(Boolean(testNumber.match(numberPattern.value))).toBeFalsy();
});

test('"true" is a valid boolean', () => {
const testValue = 'true';
expect(Boolean(testValue.match(booleanPattern.value))).toBe(true);
expect(Boolean(testValue.match(booleanPattern.value))).toBeTruthy();
});

test('"false" is a valid boolean', () => {
const testValue = 'false';
expect(Boolean(testValue.match(booleanPattern.value))).toBe(true);
expect(Boolean(testValue.match(booleanPattern.value))).toBeTruthy();
});

test('"random" is not a valid boolean', () => {
const testValue = 'random';
expect(Boolean(testValue.match(booleanPattern.value))).toBe(false);
expect(Boolean(testValue.match(booleanPattern.value))).toBeFalsy();
});

test('number is not a valid boolean', () => {
const testValue = '0';
expect(Boolean(testValue.match(booleanPattern.value))).toBe(false);
expect(Boolean(testValue.match(booleanPattern.value))).toBeFalsy();
});

test('negative number is not a valid boolean', () => {
const testValue = '-1';
expect(Boolean(testValue.match(booleanPattern.value))).toBe(false);
expect(Boolean(testValue.match(booleanPattern.value))).toBeFalsy();
});

test('"m0dule" is a valid module path"', () => {
const testValue = 'package';
expect(Boolean(testValue.match(moduleNamePattern.value))).toBe(true);
expect(Boolean(testValue.match(moduleNamePattern.value))).toBeTruthy();
});

test('"Module2" is a valid module path"', () => {
const testValue = 'Module2';
expect(Boolean(testValue.match(moduleNamePattern.value))).toBe(true);
expect(Boolean(testValue.match(moduleNamePattern.value))).toBeTruthy();
});

test('"Module.base2" is a valid module path"', () => {
const testValue = 'Module.base2';
expect(Boolean(testValue.match(moduleNamePattern.value))).toBe(true);
expect(Boolean(testValue.match(moduleNamePattern.value))).toBeTruthy();
});

test('"P/M" is not a valid module path"', () => {
const testValue = 'P/M';
expect(Boolean(testValue.match(moduleNamePattern.value))).toBe(false);
expect(Boolean(testValue.match(moduleNamePattern.value))).toBeFalsy();
});

test('"P/234" is not a valid module name"', () => {
const testValue = 'P/234';
expect(Boolean(testValue.match(moduleNamePattern.value))).toBe(false);
expect(Boolean(testValue.match(moduleNamePattern.value))).toBeFalsy();
});

test('"P_module" is a valid module path"', () => {
const testValue = 'P_module';
expect(Boolean(testValue.match(moduleNamePattern.value))).toBe(true);
expect(Boolean(testValue.match(moduleNamePattern.value))).toBeTruthy();
});

test('"module.base" is not a valid module path"', () => {
const testValue = 'module.base';
expect(Boolean(testValue.match(moduleNamePattern.value))).toBe(true);
expect(Boolean(testValue.match(moduleNamePattern.value))).toBeTruthy();
});
Loading