mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
roomId property
This commit is contained in:
parent
90bf1881f7
commit
5d4c4f3c98
@ -9,6 +9,7 @@ export const createRoomMutation = () => {
|
|||||||
userId: $userId
|
userId: $userId
|
||||||
) {
|
) {
|
||||||
id
|
id
|
||||||
|
roomId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@ -19,6 +20,7 @@ export const roomQuery = () => {
|
|||||||
query {
|
query {
|
||||||
Room {
|
Room {
|
||||||
id
|
id
|
||||||
|
roomId
|
||||||
users {
|
users {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,16 +93,18 @@ describe('Room', () => {
|
|||||||
|
|
||||||
describe('user id exists', () => {
|
describe('user id exists', () => {
|
||||||
it('returns the id of the room', async () => {
|
it('returns the id of the room', async () => {
|
||||||
await expect(mutate({
|
const result = await mutate({
|
||||||
mutation: createRoomMutation(),
|
mutation: createRoomMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
userId: 'other-chatting-user',
|
userId: 'other-chatting-user',
|
||||||
},
|
},
|
||||||
})).resolves.toMatchObject({
|
})
|
||||||
|
expect(result).toMatchObject({
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
data: {
|
data: {
|
||||||
CreateRoom: {
|
CreateRoom: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
|
roomId: result.data.CreateRoom.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -131,12 +133,14 @@ describe('Room', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('returns the room', async () => {
|
it('returns the room', async () => {
|
||||||
await expect(query({ query: roomQuery() })).resolves.toMatchObject({
|
const result = await query({ query: roomQuery() })
|
||||||
|
expect(result).toMatchObject({
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
data: {
|
data: {
|
||||||
Room: [
|
Room: [
|
||||||
{
|
{
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
|
roomId: result.data.Room[0].id,
|
||||||
users: expect.arrayContaining([
|
users: expect.arrayContaining([
|
||||||
{
|
{
|
||||||
id: 'chatting-user',
|
id: 'chatting-user',
|
||||||
@ -158,12 +162,14 @@ describe('Room', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('returns the room', async () => {
|
it('returns the room', async () => {
|
||||||
await expect(query({ query: roomQuery() })).resolves.toMatchObject({
|
const result = await query({ query: roomQuery() })
|
||||||
|
expect(result).toMatchObject({
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
data: {
|
data: {
|
||||||
Room: [
|
Room: [
|
||||||
{
|
{
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
|
roomId: result.data.Room[0].id,
|
||||||
users: expect.arrayContaining([
|
users: expect.arrayContaining([
|
||||||
{
|
{
|
||||||
id: 'chatting-user',
|
id: 'chatting-user',
|
||||||
|
|||||||
@ -38,6 +38,9 @@ export default {
|
|||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
const room = await writeTxResultPromise
|
const room = await writeTxResultPromise
|
||||||
|
if (room) {
|
||||||
|
room.roomId = room.id
|
||||||
|
}
|
||||||
return room
|
return room
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(error)
|
throw new Error(error)
|
||||||
|
|||||||
@ -10,7 +10,9 @@ type Room {
|
|||||||
createdAt: String
|
createdAt: String
|
||||||
updatedAt: String
|
updatedAt: String
|
||||||
|
|
||||||
users: [User]! @relation(name: "CHATS_IN", direction: "IN")
|
users: [User]! @relation(name: "CHATS_IN", direction: "IN")
|
||||||
|
|
||||||
|
roomId: String! @cypher(statement: "RETURN this.id")
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user