-
Notifications
You must be signed in to change notification settings - Fork 16
/
loadPosts.spec.ts
27 lines (23 loc) · 1.05 KB
/
loadPosts.spec.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
import { regularPostId, commentIdOnRegularPost, commentIdOnSharedPost, sharedCommentId, sharedPostId } from './mocks/PostMocks'
import { findBlogs, findPosts, findProfiles } from './mocks/MocksDB'
import { loadAndSetPostRelatedStructs } from '../src/loadPostStructs'
const methods = {
findBlogs,
findPosts,
findProfiles
}
const opts = { withOwner: true, withBlog: true }
test('Load regular and shared post', async () => {
const ids = [ regularPostId, sharedPostId ]
const posts = await findPosts(ids);
const results = await loadAndSetPostRelatedStructs(posts, methods, opts)
console.log('Regular and shared post: ', results)
expect(results.length).toBe(posts.length)
})
test('Load comment on regular and shared post, also shared comment post', async () => {
const ids = [ commentIdOnRegularPost, commentIdOnSharedPost, sharedCommentId ]
const posts = await findPosts(ids);
const results = await loadAndSetPostRelatedStructs(posts, methods, opts)
console.log('Comment and shared comment post: ', results)
expect(results.length).toBe(posts.length)
})