2023-05-26 17:35:52 +02:00
|
|
|
import { mount } from "@vue/test-utils";
|
2020-12-03 17:22:05 +01:00
|
|
|
import ReportCard from "@/components/Report/ReportCard.vue";
|
|
|
|
import { ActorType } from "@/types/enums";
|
2022-07-12 10:55:28 +02:00
|
|
|
import { describe, expect, it } from "vitest";
|
2020-12-03 17:22:05 +01:00
|
|
|
|
|
|
|
const reportData = {
|
|
|
|
id: "1",
|
|
|
|
content: "My content",
|
|
|
|
insertedAt: "2020-12-02T09:01:20.873Z",
|
|
|
|
reporter: {
|
2022-07-12 10:55:28 +02:00
|
|
|
preferredUsername: "John Snow",
|
2020-12-03 17:22:05 +01:00
|
|
|
domain: null,
|
|
|
|
name: "Reporter of Things",
|
|
|
|
type: ActorType.PERSON,
|
|
|
|
},
|
|
|
|
reported: {
|
|
|
|
preferredUsername: "my-awesome-group",
|
|
|
|
domain: null,
|
|
|
|
name: "My Awesome Group",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const generateWrapper = (customReportData: Record<string, unknown> = {}) => {
|
|
|
|
return mount(ReportCard, {
|
|
|
|
propsData: {
|
|
|
|
report: { ...reportData, ...customReportData },
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
describe("ReportCard", () => {
|
|
|
|
it("renders report card with basic informations", () => {
|
|
|
|
const wrapper = generateWrapper();
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
expect(wrapper.find(".flex.gap-1 div p:first-child").text()).toBe(
|
2020-12-03 17:22:05 +01:00
|
|
|
reportData.reported.name
|
|
|
|
);
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
expect(wrapper.find(".flex.gap-1 div p:nth-child(2)").text()).toBe(
|
2020-12-03 17:22:05 +01:00
|
|
|
`@${reportData.reported.preferredUsername}`
|
|
|
|
);
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
expect(wrapper.find(".reported_by div:first-child").text()).toBe(
|
|
|
|
`Reported by John Snow`
|
2020-12-03 17:22:05 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("renders report card with with a remote reporter", () => {
|
|
|
|
const wrapper = generateWrapper({
|
|
|
|
reporter: { domain: "somewhere.else", type: ActorType.APPLICATION },
|
|
|
|
});
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
expect(wrapper.find(".reported_by div:first-child").text()).toBe(
|
|
|
|
"Reported by someone on somewhere.else"
|
2020-12-03 17:22:05 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|