Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Fix client test coverage #9703

Merged
merged 11 commits into from
Nov 8, 2024
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%]');
});
});
florian-glombik marked this conversation as resolved.
Show resolved Hide resolved

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