Skip to content

Commit

Permalink
Migrate components/model tests to jest
Browse files Browse the repository at this point in the history
  • Loading branch information
tkleinke committed Jul 5, 2024
1 parent f34fdfa commit 97b7e32
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 88 deletions.
1 change: 1 addition & 0 deletions desktop/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ const config: Config = {

// The glob patterns Jest uses to detect test files
testMatch: [
'<rootDir>/test/unit/components/model/**/*.spec.ts',
'<rootDir>/test/unit/components/project/**/*.spec.ts',
'<rootDir>/test/unit/components/resources/**/*.spec.ts',
'<rootDir>/test/unit/services/**/*.spec.ts',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, test } from '@jest/globals';
import { ProjectIdentifierValidation } from '../../../../src/app/model/project-identifier-validation';


Expand All @@ -6,15 +7,15 @@ import { ProjectIdentifierValidation } from '../../../../src/app/model/project-i
*/
describe('ProjectIdentifierValidator', () => {

it('validate project identifier: allowed identifier', () => {
test('validate project identifier: allowed identifier', () => {

expect(ProjectIdentifierValidation.validate('project1')).toBeUndefined();
expect(ProjectIdentifierValidation.validate('project-identifier')).toBeUndefined();
expect(ProjectIdentifierValidation.validate('project_identifier')).toBeUndefined();
});


it('validate project identifier: unallowed characters', () => {
test('validate project identifier: unallowed characters', () => {

expect(ProjectIdentifierValidation.validate('project$'))
.toEqual([ProjectIdentifierValidation.Errors.PROJECT_IDENTIFIER_ERROR_CHARACTERS]);
Expand All @@ -25,7 +26,7 @@ describe('ProjectIdentifierValidator', () => {
});


it('validate project identifier: first character is not a letter', () => {
test('validate project identifier: first character is not a letter', () => {

expect(ProjectIdentifierValidation.validate('1project'))
.toEqual([ProjectIdentifierValidation.Errors.PROJECT_IDENTIFIER_ERROR_STARTING_CHARACTER]);
Expand All @@ -36,7 +37,7 @@ describe('ProjectIdentifierValidator', () => {
});


it('validate project identifier: wrong length', () => {
test('validate project identifier: wrong length', () => {

const projectIdentifier: string = 'project_identifier_with_too_many_characters';
const expectedLengthDifference: number =
Expand All @@ -50,14 +51,14 @@ describe('ProjectIdentifierValidator', () => {
});


it('validate project identifier: already existing identifier', () => {
test('validate project identifier: already existing identifier', () => {

expect(ProjectIdentifierValidation.validate('project1', ['project1']))
.toEqual([ProjectIdentifierValidation.Errors.PROJECT_IDENTIFIER_ERROR_EXISTS, 'project1']);
});


it('validate project identifier: no identifier', () => {
test('validate project identifier: no identifier', () => {

expect(ProjectIdentifierValidation.validate(''))
.toEqual([ProjectIdentifierValidation.Errors.PROJECT_IDENTIFIER_ERROR_MISSING]);
Expand All @@ -66,7 +67,7 @@ describe('ProjectIdentifierValidator', () => {
});


it('test project identifier similarity', () => {
test('test project identifier similarity', () => {

expect(ProjectIdentifierValidation.isSimilar('project', 'project-test')).toBe(true);
expect(ProjectIdentifierValidation.isSimilar('project', 'test-project')).toBe(true);
Expand Down
Loading

0 comments on commit 97b7e32

Please sign in to comment.