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

N21-939 api generation #2854

Merged
merged 11 commits into from
Oct 16, 2023
28 changes: 28 additions & 0 deletions src/serverApi/v3/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@ export enum ChangeLanguageParamsLanguageEnum {
* @interface ClassInfoResponse
*/
export interface ClassInfoResponse {
/**
*
* @type {string}
* @memberof ClassInfoResponse
*/
id: string;
/**
*
* @type {string}
* @memberof ClassInfoResponse
*/
type: ClassInfoResponseTypeEnum;
/**
*
* @type {string}
Expand All @@ -383,7 +395,23 @@ export interface ClassInfoResponse {
* @memberof ClassInfoResponse
*/
teachers: Array<string>;
/**
*
* @type {string}
* @memberof ClassInfoResponse
*/
schoolYear?: string;
}

/**
* @export
* @enum {string}
*/
export enum ClassInfoResponseTypeEnum {
Class = 'class',
Group = 'group'
}

/**
*
* @export
Expand Down
11 changes: 9 additions & 2 deletions src/store/group.unit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as serverApi from "@/serverApi/v3/api";
import { ClassInfoResponseTypeEnum } from "@/serverApi/v3/api";
import {
ClassInfoResponse,
ClassInfoSearchListResponse,
Expand All @@ -14,7 +15,7 @@ import { ClassInfo } from "./types/class-info";
import { BusinessError, Pagination } from "./types/commons";
import { SortOrder } from "./types/sort-order.enum";
import GroupModule from "./group";
import { DeepMocked, createMock } from "@golevelup/ts-jest";
import { createMock, DeepMocked } from "@golevelup/ts-jest";
import { mockApiResponse } from "@@/tests/test-utils/mockApiResponse";
import { mapAxiosErrorToResponseError } from "@/utils/api";

Expand Down Expand Up @@ -86,7 +87,13 @@ describe("GroupModule", () => {

it("should return the changed state", () => {
const classes: ClassInfo[] = [
{ name: "3a", externalSourceName: "Klasse", teachers: ["Carlie"] },
{
name: "3a",
externalSourceName: "Klasse",
teachers: ["Carlie"],
type: ClassInfoResponseTypeEnum.Class,
MBergCap marked this conversation as resolved.
Show resolved Hide resolved
id: "id",
},
];

module.setClasses(classes);
Expand Down
2 changes: 2 additions & 0 deletions src/store/group/group.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export class GroupMapper {
name: classInfoResponse.name,
externalSourceName: classInfoResponse.externalSourceName,
teachers: classInfoResponse.teachers,
type: classInfoResponse.type,
id: classInfoResponse.id,
})
);

Expand Down
4 changes: 4 additions & 0 deletions src/store/types/class-info.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { ClassInfoResponseTypeEnum } from "../../serverApi/v3";

export type ClassInfo = {
name: string;
externalSourceName?: string;
teachers: string[];
type: ClassInfoResponseTypeEnum;
MBergCap marked this conversation as resolved.
Show resolved Hide resolved
id: string;
};
8 changes: 5 additions & 3 deletions tests/test-utils/factory/classInfoResponseFactory.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { ClassInfoResponse } from "@/serverApi/v3";
import { ClassInfoResponse, ClassInfoResponseTypeEnum } from "@/serverApi/v3";
import { Factory } from "fishery";

export const classInfoResponseFactory = Factory.define<ClassInfoResponse>(
() => ({
name: "className",
({ sequence }) => ({
name: `className${sequence}`,
externalSourceName: "Source",
teachers: ["TestTeacher"],
type: ClassInfoResponseTypeEnum.Class,
id: `id-${sequence}`,
MBergCap marked this conversation as resolved.
Show resolved Hide resolved
})
);
Loading