From c2a17d2dcb17adaf8ee189d05956b37bf1839bf5 Mon Sep 17 00:00:00 2001 From: Bernardo Raposo Date: Sun, 26 May 2019 19:37:54 +0100 Subject: [PATCH] test: add tests to comments in file --- src/__tests__/file.test.js | 50 ++++++++++++++++++++++++++++++++++++++ src/types/comments.js | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/__tests__/file.test.js b/src/__tests__/file.test.js index 6eb2e8c..8c587e8 100644 --- a/src/__tests__/file.test.js +++ b/src/__tests__/file.test.js @@ -35,4 +35,54 @@ describe("File", () => { data: { file: { images: [{ id: "0:1" }] } }, }); }); + + test("can get file comments", async () => { + const query = ` + query { + file(id: "${figmaFile}") { + comments { + id + message + file_key + order_id + parent_id + created_at + client_meta { + node_id + node_offset { + x + y + } + } + resolved_at + } + } + } + `; + + await expect(graphql(schema, query, null, { fileId: figmaFile })).resolves.toEqual({ + data: { + file: { + comments: [ + { + id: "6907475", + message: "Testing comment", + file_key: "cLp23bR627jcuNSoBGkhL04E", + order_id: 1, + parent_id: "", + created_at: "2019-05-26T17:47:36Z", + client_meta: { + node_id: "28:5", + node_offset: { + x: 111, + y: 22, + }, + }, + resolved_at: null, + }, + ], + }, + }, + }); + }); }); diff --git a/src/types/comments.js b/src/types/comments.js index c5b0785..cd92710 100644 --- a/src/types/comments.js +++ b/src/types/comments.js @@ -31,7 +31,7 @@ exports.type = ` id: ID! # The position of the comment. Either the absolute coordinates on the canvas or a relative offset within a frame - client_meta: Position + client_meta: FrameOffset # The file in which the comment lives file_key: String