-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
210 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Node returns css export 1`] = `"width: 201px; height: 109px;"`; | ||
|
||
exports[`Node returns css export 2`] = `"width: 201px; height: 109px;"`; | ||
|
||
exports[`Node returns css export 3`] = `"width: 201px; height: 109px;"`; | ||
|
||
exports[`Node returns css export 4`] = `"width: 144px; height: 62px;"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* eslint-env jest */ | ||
|
||
import { graphql } from "graphql"; | ||
import schema from "../../schema"; | ||
|
||
const figmaFile = "cLp23bR627jcuNSoBGkhL04E"; | ||
|
||
jest.setTimeout(10000); | ||
|
||
describe("Export", () => { | ||
test("returns default export image", async () => { | ||
const query = ` | ||
query { | ||
exports(id: "${figmaFile}") { | ||
id | ||
output | ||
} | ||
} | ||
`; | ||
|
||
const response = await graphql(schema, query, null, { fileId: figmaFile }); | ||
expect(response.data).toBeDefined(); | ||
|
||
const fileExports = response.data && response.data.exports; | ||
fileExports.forEach(fileExport => { | ||
const { id, output } = fileExport; | ||
expect(id).toEqual("0:1"); | ||
expect(output).not.toBeNull(); | ||
}); | ||
}); | ||
|
||
test("returns specific export image", async () => { | ||
const nodeIds = ["1:6", "28:4"]; | ||
const query = ` | ||
query { | ||
exports(id: "${figmaFile}", params: { ids: ${JSON.stringify(nodeIds)}}) { | ||
id | ||
output | ||
} | ||
} | ||
`; | ||
|
||
const response = await graphql(schema, query, null, { fileId: figmaFile }); | ||
expect(response.data).toBeDefined(); | ||
|
||
const fileExports: { id: string; output: string }[] = | ||
response.data && response.data.exports; | ||
fileExports.forEach((fileExport, index) => { | ||
const { id, output } = fileExport; | ||
expect(id).toEqual(nodeIds[index]); | ||
expect(output).not.toBeNull(); | ||
}); | ||
}); | ||
|
||
test("returns svg format export", async () => { | ||
const query = ` | ||
query { | ||
exports(id: "${figmaFile}", params: { format:svg }) { | ||
id | ||
output | ||
} | ||
} | ||
`; | ||
|
||
const response = await graphql(schema, query, null, { fileId: figmaFile }); | ||
expect(response.data).toBeDefined(); | ||
|
||
const fileExports = response.data && response.data.exports; | ||
fileExports.forEach(fileExport => { | ||
const { id, output } = fileExport; | ||
expect(id).toEqual("0:1"); | ||
expect(output).not.toBeNull(); | ||
}); | ||
}); | ||
|
||
test("returns jpg format export", async () => { | ||
const query = ` | ||
query { | ||
exports(id: "${figmaFile}", params: { format:jpg }) { | ||
id | ||
output | ||
} | ||
} | ||
`; | ||
|
||
const response = await graphql(schema, query, null, { fileId: figmaFile }); | ||
expect(response.data).toBeDefined(); | ||
|
||
const fileExports = response.data && response.data.exports; | ||
fileExports.forEach(fileExport => { | ||
const { id, output } = fileExport; | ||
expect(id).toEqual("0:1"); | ||
expect(output).not.toBeNull(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* eslint-env jest */ | ||
|
||
import { graphql } from "graphql"; | ||
import schema from "../../schema"; | ||
|
||
const figmaFile = "cLp23bR627jcuNSoBGkhL04E"; | ||
|
||
jest.setTimeout(10000); | ||
|
||
describe("Node", () => { | ||
test("returns default export image", async () => { | ||
const query = ` | ||
query { | ||
file(id: "${figmaFile}") { | ||
rectangles { | ||
export | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const response = await graphql(schema, query, null, { fileId: figmaFile }); | ||
expect(response.data).not.toBeUndefined(); | ||
|
||
const rectangles = response.data && response.data.file.rectangles; | ||
rectangles.forEach(rectangle => { | ||
const { export: nodeExport } = rectangle; | ||
expect(nodeExport).not.toBeNull(); | ||
}); | ||
}); | ||
|
||
test("returns jpg export", async () => { | ||
const query = ` | ||
query { | ||
file(id: "${figmaFile}") { | ||
rectangles { | ||
export(params: { format: jpg }) | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const response = await graphql(schema, query, null, { fileId: figmaFile }); | ||
expect(response.data).not.toBeUndefined(); | ||
|
||
const rectangles = response.data && response.data.file.rectangles; | ||
rectangles.forEach(rectangle => { | ||
const { export: nodeExport } = rectangle; | ||
expect(nodeExport).not.toBeNull(); | ||
}); | ||
}); | ||
|
||
test("returns css export", async () => { | ||
const query = ` | ||
query { | ||
file(id: "${figmaFile}") { | ||
rectangles { | ||
export(params: { format: css }) | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const response = await graphql(schema, query, null, { fileId: figmaFile }); | ||
expect(response.data).not.toBeUndefined(); | ||
|
||
const rectangles = response.data && response.data.file.rectangles; | ||
rectangles.forEach(rectangle => { | ||
const { export: nodeExport } = rectangle; | ||
expect(nodeExport).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |