Skip to content

Commit

Permalink
fix: return only running fairs
Browse files Browse the repository at this point in the history
  • Loading branch information
dimatretyak committed Sep 14, 2021
1 parent c9ecef0 commit 80ba6ee
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/schema/v2/home/__tests__/home_page_artwork_modules.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable promise/always-return */
import { map, find } from "lodash"
import moment from "moment"
import { runAuthenticatedQuery } from "schema/v2/test/utils"

describe("HomePageArtworkModules", () => {
Expand Down Expand Up @@ -355,4 +356,41 @@ describe("HomePageArtworkModules", () => {
expect(keys).toEqual(["followed_galleries"])
})
})

it("returns first running fair", async () => {
const query = `
{
homePage {
artworkModules(
maxFollowedGeneRails: -1
include: [CURRENT_FAIRS]
) {
key
title
}
}
}`

context.fairsLoader = () =>
Promise.resolve({
body: [
{
start_at: moment().add(1, "day"),
end_at: moment().add(10, "day"),
has_homepage_section: true,
name: "fair-1",
},
{
start_at: moment().subtract(2, "day"),
end_at: moment().add(2, "day"),
has_homepage_section: true,
name: "fair-2",
},
],
})

const { homePage } = await runAuthenticatedQuery(query, context)

expect(homePage.artworkModules[0].title).toBe("fair-1")
})
})
1 change: 1 addition & 0 deletions src/schema/v2/home/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const featuredFair = (
return fairsLoader({
size: 5,
active: true,
status: "running",
has_homepage_section: true,
}).then(({ body: fairs }) => {
if (fairs.length) {
Expand Down

0 comments on commit 80ba6ee

Please sign in to comment.