mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
Frontend integration tests: Create mock mac admins handler (#8728)
This commit is contained in:
parent
9b709b23a9
commit
82d1c13b44
24
frontend/__mocks__/macAdminsMock.ts
Normal file
24
frontend/__mocks__/macAdminsMock.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { IMacadminsResponse } from "interfaces/host";
|
||||
|
||||
const DEFAULT_MAC_ADMINS_MOCK: IMacadminsResponse = {
|
||||
macadmins: {
|
||||
mobile_device_management: {
|
||||
enrollment_status: "Enrolled (manual)",
|
||||
server_url: "https://kandji.com/2",
|
||||
name: "Kandji",
|
||||
id: 11,
|
||||
},
|
||||
munki: {
|
||||
version: "1.2.3",
|
||||
},
|
||||
munki_issues: [],
|
||||
},
|
||||
};
|
||||
|
||||
const createMockMacAdmins = (
|
||||
overrides?: Partial<IMacadminsResponse>
|
||||
): IMacadminsResponse => {
|
||||
return { ...DEFAULT_MAC_ADMINS_MOCK, ...overrides };
|
||||
};
|
||||
|
||||
export default createMockMacAdmins;
|
@ -87,6 +87,8 @@ export interface IMunkiData {
|
||||
export interface IMDMData {
|
||||
enrollment_status: string;
|
||||
server_url: string;
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface IMunkiIssue {
|
||||
|
@ -2,6 +2,7 @@ import { defaultActivityHandler } from "./handlers/activity-handlers";
|
||||
import {
|
||||
defaultDeviceHandler,
|
||||
defaultDeviceMappingHandler,
|
||||
defaultMacAdminsHandler,
|
||||
} from "./handlers/device-handler";
|
||||
|
||||
export const baseUrl = (path: string) => {
|
||||
@ -11,6 +12,7 @@ export const baseUrl = (path: string) => {
|
||||
const handlers = [
|
||||
defaultDeviceHandler,
|
||||
defaultDeviceMappingHandler,
|
||||
defaultMacAdminsHandler,
|
||||
defaultActivityHandler,
|
||||
];
|
||||
|
||||
|
@ -3,6 +3,7 @@ import { rest } from "msw";
|
||||
import createMockDeviceUser from "__mocks__/deviceUserMock";
|
||||
import createMockHost from "__mocks__/hostMock";
|
||||
import createMockLicense from "__mocks__/licenseMock";
|
||||
import createMockMacAdmins from "__mocks__/macAdminsMock";
|
||||
import { baseUrl } from "test/test-utils";
|
||||
|
||||
export const defaultDeviceHandler = rest.get(
|
||||
@ -29,3 +30,14 @@ export const defaultDeviceMappingHandler = rest.get(
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
export const defaultMacAdminsHandler = rest.get(
|
||||
baseUrl("/device/:token/macadmins"),
|
||||
(req, res, context) => {
|
||||
return res(
|
||||
context.json({
|
||||
macadmins: createMockMacAdmins(),
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user