|
2 | 2 | * Helpers definition from https://docs.aws.amazon.com/appsync/latest/devguide/dynamodb-helpers-in-util-dynamodb-js.html
|
3 | 3 | */
|
4 | 4 |
|
5 |
| -const { util } = require(".."); |
6 |
| -const { AppSyncClient, EvaluateCodeCommand } = require("@aws-sdk/client-appsync"); |
| 5 | +const { checkValid } = require("./helpers.js"); |
7 | 6 |
|
8 |
| -let client = null; |
9 | 7 |
|
10 | 8 | describe("dynamodb helpers", () => {
|
11 | 9 | describe.skip("toDynamoDB", () => {
|
@@ -97,49 +95,3 @@ describe("dynamodb helpers", () => {
|
97 | 95 | );
|
98 | 96 | });
|
99 | 97 | });
|
100 |
| - |
101 |
| -const runOnAWS = async (s) => { |
102 |
| - if (!client) { |
103 |
| - client = new AppSyncClient(); |
104 |
| - } |
105 |
| - |
106 |
| - const code = ` |
107 |
| - import { util } from '@aws-appsync/utils'; |
108 |
| -
|
109 |
| - export function request(ctx) { |
110 |
| - return ${s}; |
111 |
| - } |
112 |
| -
|
113 |
| - export function response(ctx) { |
114 |
| - } |
115 |
| - `; |
116 |
| - |
117 |
| - const command = new EvaluateCodeCommand({ |
118 |
| - code, |
119 |
| - context: "{}", |
120 |
| - function: "request", |
121 |
| - runtime: { |
122 |
| - name: "APPSYNC_JS", |
123 |
| - runtimeVersion: "1.0.0", |
124 |
| - }, |
125 |
| - }); |
126 |
| - |
127 |
| - const result = await client.send(command); |
128 |
| - try { |
129 |
| - return JSON.parse(result.evaluationResult); |
130 |
| - } catch (e) { |
131 |
| - console.error("invalid json", result); |
132 |
| - } |
133 |
| -} |
134 |
| - |
135 |
| -// If TEST_TARGET is AWS_CLOUD then run the check against AWS. Otherwise, run locally. |
136 |
| -const checkValid = async (s) => { |
137 |
| - let result; |
138 |
| - if (process.env.TEST_TARGET === "AWS_CLOUD") { |
139 |
| - result = await runOnAWS(s); |
140 |
| - } else { |
141 |
| - result = eval(s); |
142 |
| - } |
143 |
| - expect(result).toMatchSnapshot(); |
144 |
| -} |
145 |
| - |
0 commit comments