-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakeArticlePage.test.ts
41 lines (33 loc) · 1.26 KB
/
makeArticlePage.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import fetch from 'isomorphic-fetch'
import { makeArticlePage } from '..'
import { MOCK_ARTICLE_PAGE } from '../render/mock'
import { deserializeHtmlBundle } from './utils'
jest.mock('isomorphic-fetch')
const mockedFetch = fetch as jest.Mock
const MOCK_ARTICLE_PAGE_DATA = MOCK_ARTICLE_PAGE('matters.town')
describe('makeArticlePage', () => {
test('can generate basic HTML bundle', async () => {
mockedFetch.mockResolvedValue({
arrayBuffer: () => Promise.resolve(new ArrayBuffer(1)),
})
const { bundle } = await makeArticlePage(MOCK_ARTICLE_PAGE_DATA)
expect(deserializeHtmlBundle(bundle)).toMatchSnapshot()
})
test('can generate basic HTML bundle when `getAsset` fails', async () => {
mockedFetch.mockImplementation(() => {
throw new Error()
})
const { bundle } = await makeArticlePage(MOCK_ARTICLE_PAGE_DATA)
expect(deserializeHtmlBundle(bundle)).toMatchSnapshot()
})
test('can generate HTML bundle with payment pointer', async () => {
mockedFetch.mockResolvedValue({
arrayBuffer: () => Promise.resolve(new ArrayBuffer(1)),
})
const { bundle } = await makeArticlePage({
...MOCK_ARTICLE_PAGE_DATA,
paymentPointer: '$pay-me',
})
expect(deserializeHtmlBundle(bundle)).toMatchSnapshot()
})
})