mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Add createdAt attribute to PINNED and test
This commit is contained in:
parent
0007533b8c
commit
f1243c6df0
@ -153,7 +153,7 @@ export default {
|
||||
|
||||
updatePostCypher += `
|
||||
MATCH (user:User {id: $userId}) WHERE user.role = 'admin'
|
||||
MERGE (user)-[:PINNED]->(post)
|
||||
MERGE (user)-[:PINNED {createdAt: toString(datetime())}]->(post)
|
||||
WITH post
|
||||
`
|
||||
}
|
||||
|
||||
@ -725,20 +725,29 @@ describe('UpdatePost', () => {
|
||||
})
|
||||
|
||||
describe('removes other pinned post', () => {
|
||||
let pinnedPost
|
||||
beforeEach(async () => {
|
||||
await factory.create('Post', {
|
||||
id: 'only-pinned-post',
|
||||
author: admin,
|
||||
})
|
||||
})
|
||||
|
||||
it('leaves only one pinned post at a time', async () => {
|
||||
expect.assertions(1)
|
||||
await mutate({ mutation: updatePostMutation, variables })
|
||||
variables = { ...variables, id: 'only-pinned-post' }
|
||||
await mutate({ mutation: updatePostMutation, variables })
|
||||
const pinnedPosts = await neode.cypher(`MATCH ()-[:PINNED]->(post:Post) RETURN post`)
|
||||
expect(pinnedPosts.records).toHaveLength(1)
|
||||
pinnedPost = await neode.cypher(
|
||||
`MATCH ()-[relationship:PINNED]->(post:Post) RETURN post, relationship`,
|
||||
)
|
||||
})
|
||||
|
||||
it('leaves only one pinned post at a time', async () => {
|
||||
expect(pinnedPost.records).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('leaves only one pinned post at a time', async () => {
|
||||
const [pinnedPostCreatedAt] = pinnedPost.records.map(
|
||||
record => record.get('relationship').properties.createdAt,
|
||||
)
|
||||
expect(pinnedPostCreatedAt).toEqual(expect.any(String))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user