blob: 4fe2f50e66a688576944ea70cd7c19e3052c6f1a (
plain)
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
|
import { afterEach, describe, expect, it } from '@jest/globals';
import { fetchLastPostCursor } from './fetch-last-post-cursor';
describe('fetch-last-post-cursor', () => {
afterEach(() => {
window.history.replaceState({}, '', '/');
});
it('returns the cursor of the last WordPress post using GraphQL', async () => {
const result = await fetchLastPostCursor(2);
expect.assertions(1);
expect(result).toBe('cursor2');
});
it('rejects with an error when no posts are found', async () => {
window.history.replaceState({}, '', '/?error=true');
expect.assertions(1);
await expect(async () => fetchLastPostCursor(1)).rejects.toEqual(
new Error('Unable to find the cursor of the last post.')
);
});
});
|