This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mockConfigUpdate = jest.fn(); | |
const mockS3putObjectPromise = jest.fn().mockResolvedValue(); | |
const mockS3putObject = jest.fn().mockImplementation(() => ({ | |
promise: mockS3putObjectPromise, | |
})); | |
const mockS3 = jest.fn().mockImplementation(() => ({ | |
putObject: mockS3putObject, | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createIsRecentArticle } from "./is-recent-article"; | |
import { articleToXml } from "./article-to-xml"; | |
import { createExecuteLatestArticlesQuery } from "./execute-latest-articles-query"; | |
export const createRecentArticlesSitemap = ({ | |
todayDate, | |
executeLatestArticlesQuery = createExecuteLatestArticlesQuery(), | |
}) => { | |
const isRecentArticle = createIsRecentArticle(todayDate); | |
return async ({ domain, language }) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createRecentArticlesSitemap } from "../recent-articles-sitemap"; | |
import { | |
createTestArticlePublishedOneDayAgo, | |
createTestArticlePublishedTwoDaysAgo, | |
createTestArticlePublishedThreeDaysAgo, | |
} from "./data/create-test-article"; | |
import { createFakeExecuteLatestArticlesQuery } from "../execute-latest-articles-query"; | |
describe("recentArticlesSitemap", () => { | |
it("generates the sitemap xml of the latest articles for a specific domain and language", async () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
export class GraphQLError extends Error { | |
constructor(graphQLErrors = []) { | |
super(); | |
this.message = `GraphQL errors : ${graphQLErrors | |
.map(({ message }) => message) | |
.join("\n")}`; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fakeSendQuery = (articlesForDomain) => (request) => | |
Promise.resolve({ | |
data: { | |
data: { | |
latestArticles: articlesForDomain[request.headers.domain], | |
}, | |
}, | |
}); | |
export const createFakeExecuteLatestArticlesQuery = (articlesForDomain) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* [...] */ | |
export const createFakeExecuteLatestArticlesQuery = (articlesForDomain) => | |
createExecuteLatestArticlesQuery({ | |
sendQuery: fakeSendQuery(articlesForDomain), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createTestServer } from "./test-server"; | |
import { | |
createExecuteLatestArticlesQuery, | |
createFakeExecuteLatestArticlesQuery, | |
GraphQLError, | |
} from "../execute-latest-articles-query"; | |
import { createTestArticlePublishedOneDayAgo } from "./data/create-test-article"; | |
describe("executeLatestArticlesQuery", () => { | |
let testServer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
export class GraphQLError extends Error { | |
constructor(graphQLErrors = []) { | |
super(); | |
this.message = `GraphQL errors : ${graphQLErrors | |
.map(({ message }) => message) | |
.join("\n")}`; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
export class GraphQLError extends Error { | |
constructor(graphQLErrors = []) { | |
super(); | |
this.message = `GraphQL errors : ${graphQLErrors | |
.map(({ message }) => message) | |
.join("\n")}`; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createTestServer } from "./test-server"; | |
import { | |
executeLatestArticlesQuery, | |
GraphQLError, | |
} from "../execute-latest-articles-query"; | |
import { createTestArticlePublishedOneDayAgo } from "./data/create-test-article"; | |
describe("executeLatestArticlesQuery", () => { | |
let testServer; | |
beforeAll((done) => { |