Fix js unit tests

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-04-08 09:53:46 +02:00
parent ca14745d40
commit 1a43bfb620
7 changed files with 63 additions and 17 deletions

View File

@@ -37,7 +37,7 @@ describe("CommentTree", () => {
let requestHandlers: Record<string, RequestHandler>;
const generateWrapper = (handlers = {}, baseData = {}) => {
const cache = new InMemoryCache({ addTypename: false });
const cache = new InMemoryCache({ addTypename: true });
mockClient = createMockClient({
cache,
@@ -88,10 +88,13 @@ describe("CommentTree", () => {
it("renders a comment tree", async () => {
generateWrapper();
expect(wrapper.findComponent({ name: "b-notification" }).text()).toBe(
"The organiser has chosen to close comments."
);
expect(wrapper.exists()).toBe(true);
expect(wrapper.find(".loading").text()).toBe("Loading comments…");
await wrapper.vm.$nextTick();
await wrapper.vm.$nextTick(); // because of the <transition>
expect(wrapper.find(".no-comments").text()).toBe("No comments yet");
expect(wrapper.html()).toMatchSnapshot();
});

View File

@@ -2,21 +2,26 @@
exports[`CommentTree renders a comment tree 1`] = `
<div>
<b-notification-stub active="true" duration="2000" animation="fade">The organiser has chosen to close comments.</b-notification-stub>
<p class="loading has-text-centered">
Loading comments…
</p>
</div>
`;
exports[`CommentTree renders a comment tree 2`] = `
<div>
<b-notification-stub active="true" duration="2000" animation="fade">The organiser has chosen to close comments.</b-notification-stub>
<!---->
<transition-stub name="comment-empty-list" mode="out-in">
<transition-group-stub tag="ul" name="comment-list" class="comment-list">
<comment-stub comment="[object Object]" event="[object Object]" class="root-comment"></comment-stub>
<comment-stub comment="[object Object]" event="[object Object]" class="root-comment"></comment-stub>
</transition-group-stub>
<div class="no-comments"><span>No comments yet</span></div>
</transition-stub>
</div>
`;
exports[`CommentTree renders a comment tree 2`] = `
<div>
<!---->
<transition-stub name="comment-empty-list" mode="out-in">
<transition-group-stub tag="ul" name="comment-list" class="comment-list">
<comment-stub comment="[object Object]" event="[object Object]" class="root-comment"></comment-stub>
<comment-stub comment="[object Object]" event="[object Object]" class="root-comment"></comment-stub>
</transition-group-stub>
<div class="no-comments"><span>No comments yet</span></div>
</transition-stub>
</div>
`;

View File

@@ -42,7 +42,7 @@ describe("ParticipationSection", () => {
customProps: Record<string, unknown> = {},
baseData: Record<string, unknown> = {}
) => {
const cache = new InMemoryCache({ addTypename: false });
const cache = new InMemoryCache({ addTypename: true });
mockClient = createMockClient({
cache,

View File

@@ -65,7 +65,7 @@ describe("ParticipationWithoutAccount", () => {
customProps: Record<string, unknown> = {},
baseData: Record<string, unknown> = {}
) => {
const cache = new InMemoryCache({ addTypename: false });
const cache = new InMemoryCache({ addTypename: true });
mockClient = createMockClient({
cache,

View File

@@ -25,7 +25,7 @@ describe("App component", () => {
let requestHandlers: Record<string, RequestHandler>;
const createComponent = (handlers = {}, baseData = {}) => {
const cache = new InMemoryCache({ addTypename: false });
const cache = new InMemoryCache({ addTypename: true });
mockClient = createMockClient({
cache,