Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JulissaDantes committed Jul 24, 2024
1 parent 108ec20 commit 59c99a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/runtime/test/__snapshots__/runtime.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ type Favorite implements Node {
tag: String!
note: String
docID: CeramicStreamID!
extra: String
doc: Node
}
Expand Down Expand Up @@ -453,6 +454,7 @@ input FavoriteInput {
tag: String!
note: String
docID: CeramicStreamID!
extra: String
}
input SetOptionsInput {
Expand Down Expand Up @@ -1649,6 +1651,7 @@ type Post implements Node & TestInterface {
date: DateTime
text: String!
title: String!
testList: [String]
testField: String
"""Account controlling the document"""
Expand Down Expand Up @@ -1759,6 +1762,7 @@ input PostInput {
date: DateTime
text: String!
title: String!
testList: [String]
testField: String
}
Expand Down Expand Up @@ -1806,6 +1810,7 @@ scalar CeramicCommitID @specifiedBy(url: "https://cips.ceramic.network/CIPs/cip-
input PartialPostInput {
date: DateTime
text: String
testList: [String]
}
type EnableIndexingPostPayload {
Expand Down
12 changes: 9 additions & 3 deletions packages/runtime/test/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,14 @@ describe('runtime', () => {
title: String! @string(minLength: 10, maxLength: 100) @immutable
text: String! @string(maxLength: 2000)
testField: String @string(maxLength: 50)
testList: [String] @string(maxLength: 5) @list(maxLength: 5) @immutable
}
`
const originalTitle = 'An Original Post'
const date = '2024-01-01T10:15:30Z'
const text = 'First post content'
const testField = 'A test field'
const testList = ['a', 'b', 'c']

const composite = await Composite.create({ ceramic, schema: postWithImmutableFieldSchema })
const definition = composite.toRuntime()
Expand Down Expand Up @@ -1022,6 +1024,7 @@ describe('runtime', () => {
text,
date,
testField,
testList,
},
},
},
Expand All @@ -1042,13 +1045,16 @@ describe('runtime', () => {
}`

const res2 = await runtime.executeQuery(updatePost, {
i: { id: docID, content: { title: 'A different title' } },
i: { id: docID, content: { title: 'A different title' }, testList: ['d', 'e'] },
})

expect(res2.errors).toBeDefined()
expect(res2.errors?.length).toBe(2)
expect(res2.errors![0].message).toEqual(
`Variable "$i" got invalid value { title: "A different title" } at "i.content"; Field "title" is not defined by type "PartialPostInput". Did you mean "date"?`,
)
expect(res2.errors![1].message).toContain(
`Field "testList" is not defined by type "UpdatePostInput"`,
)
}, 60000)

test('toggling `shouldIndex` metadata', async () => {
Expand Down

0 comments on commit 59c99a2

Please sign in to comment.