Improve post & events cards, homepage and my events page
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -4,6 +4,8 @@ import Buefy from "buefy";
|
||||
import VueRouter from "vue-router";
|
||||
import { routes } from "@/router";
|
||||
import { enUS } from "date-fns/locale";
|
||||
import { formatDateTimeString } from "@/filters/datetime";
|
||||
import { i18n } from "@/utils/i18n";
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Buefy);
|
||||
@@ -20,14 +22,23 @@ const postData = {
|
||||
title: "My Blog Post",
|
||||
body: "My content",
|
||||
insertedAt: "2020-12-02T09:01:20.873Z",
|
||||
tags: [],
|
||||
};
|
||||
|
||||
const generateWrapper = (customPostData: Record<string, unknown> = {}) => {
|
||||
const generateWrapper = (
|
||||
customPostData: Record<string, unknown> = {},
|
||||
customProps: Record<string, unknown> = {}
|
||||
) => {
|
||||
return mount(PostListItem, {
|
||||
localVue,
|
||||
router,
|
||||
i18n,
|
||||
propsData: {
|
||||
post: { ...postData, ...customPostData },
|
||||
...customProps,
|
||||
},
|
||||
filters: {
|
||||
formatDateTimeString,
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -36,14 +47,40 @@ describe("PostListItem", () => {
|
||||
it("renders post list item with basic informations", () => {
|
||||
const wrapper = generateWrapper();
|
||||
|
||||
// can't use the snapshot feature because of `ago`
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
|
||||
expect(
|
||||
wrapper.find("a.post-minimalist-card-wrapper").attributes("href")
|
||||
).toBe(`/p/${postData.slug}`);
|
||||
|
||||
expect(wrapper.find(".post-minimalist-title").text()).toContain(
|
||||
postData.title
|
||||
expect(wrapper.find(".post-minimalist-title").text()).toBe(postData.title);
|
||||
|
||||
expect(wrapper.find(".post-publication-date").text()).toBe("Dec 2, 2020");
|
||||
|
||||
expect(wrapper.find(".post-publisher").exists()).toBeFalsy();
|
||||
});
|
||||
|
||||
it("renders post list item with tags", () => {
|
||||
const wrapper = generateWrapper({
|
||||
tags: [{ slug: "a-tag", title: "A tag" }],
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
|
||||
expect(wrapper.find(".tags").text()).toContain("A tag");
|
||||
|
||||
expect(wrapper.find(".post-publisher").exists()).toBeFalsy();
|
||||
});
|
||||
|
||||
it("renders post list item with publisher name", () => {
|
||||
const wrapper = generateWrapper(
|
||||
{ author: { name: "An author" } },
|
||||
{ isCurrentActorMember: true }
|
||||
);
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
|
||||
expect(wrapper.find(".post-publisher").exists()).toBeTruthy();
|
||||
expect(wrapper.find(".post-publisher").text()).toContain("An author");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user