Skip to content

Commit

Permalink
Development: Fix client test coverage (#9703)
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-glombik authored Nov 8, 2024
1 parent 3bff129 commit 25146ba
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/javascript/spec/util/shared/request.util.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createNestedRequestOption } from 'app/shared/util/request.util';
import { HttpParams } from '@angular/common/http';

describe('createNestedRequestOption', () => {
it('should create HttpParams with nested keys', () => {
const req = { key1: 'value1', key2: 'value2' };
const parentKey = 'parent';
const params: HttpParams = createNestedRequestOption(req, parentKey);

expect(params.get('parent.key1')).toBe('value1');
expect(params.get('parent.key2')).toBe('value2');
});

it('should create HttpParams without parent key', () => {
const req = { key1: 'value1', key2: 'value2' };
const params: HttpParams = createNestedRequestOption(req);

expect(params.get('key1')).toBe('value1');
expect(params.get('key2')).toBe('value2');
});

it('should append sort parameters', () => {
const req = { sort: ['value1', 'value2'] };
const parentKey = 'parent';
const params: HttpParams = createNestedRequestOption(req, parentKey);

expect(params.getAll('parent.sort')).toEqual(['value1', 'value2']);
});

it('should handle empty request object', () => {
const params: HttpParams = createNestedRequestOption();

expect(params.keys()).toHaveLength(0);
});
});
11 changes: 11 additions & 0 deletions src/test/javascript/spec/util/shared/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from 'app/shared/util/utils';
import { Exercise } from 'app/entities/exercise.model';
import { Course } from 'app/entities/course.model';
import { Range } from 'app/shared/util/utils';

describe('Round', () => {
it('Decimal length', () => {
Expand Down Expand Up @@ -91,6 +92,16 @@ describe('average', () => {
});
});

describe('Range', () => {
it('should return the correct string representation', () => {
const range = new Range(10, 50);
expect(range.toString()).toBe('[10%, 50%)');

const rangeInclusive = new Range(0, 100);
expect(rangeInclusive.toString()).toBe('[0%, 100%]');
});
});

describe('getAsMutableObject', () => {
it('should return immutable object as mutable object', () => {
const immutableObject = Object.freeze({
Expand Down

0 comments on commit 25146ba

Please sign in to comment.