appsync-template-tester
Advanced tools
Comparing version 1.0.3 to 1.0.4
export default class Parser { | ||
private template; | ||
constructor(template: string); | ||
/** | ||
* Resolve as a string | ||
*/ | ||
resolve(context: Context): string; | ||
/** | ||
* Resolve and JSON parse the response | ||
*/ | ||
resolveParse(context: Context): Object; | ||
} | ||
@@ -6,0 +13,0 @@ export declare type Context = { |
@@ -18,2 +18,5 @@ "use strict"; | ||
} | ||
/** | ||
* Resolve as a string | ||
*/ | ||
resolve(context) { | ||
@@ -33,4 +36,11 @@ const clonedContext = JSON.parse(JSON.stringify(context)); | ||
} | ||
/** | ||
* Resolve and JSON parse the response | ||
*/ | ||
resolveParse(context) { | ||
const res = this.resolve(context); | ||
return JSON.parse(res); | ||
} | ||
} | ||
exports.default = Parser; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsZ0RBQWdEO0FBQ2hELDJDQUFvQztBQUNwQyxpREFBbUM7QUFDbkMsa0RBQW9DO0FBRXBDLE1BQXFCLE1BQU07SUFHekIsWUFBWSxRQUFnQjtRQUMxQixJQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQztJQUMzQixDQUFDO0lBRU0sT0FBTyxDQUFDLE9BQWdCO1FBQzdCLE1BQU0sYUFBYSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDO1FBRTFELE1BQU0sSUFBSSxHQUFHO1lBQ1gsR0FBRyxRQUFRO1lBQ1gsSUFBSTtTQUNMLENBQUM7UUFFRixNQUFNLE1BQU0sR0FBRztZQUNiLE9BQU8sRUFBRSxhQUFhO1lBQ3RCLEdBQUcsRUFBRSxhQUFhO1lBQ2xC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0FBQyxFQUFFLENBQUMsQ0FBQztJQUNsQyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLENBQUMsQ0FBQyxDQUFDO0FBQ3RELENBQUMsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFBhcnNlciBmcm9tICcuLi9pbmRleCc7XG5cbnRlc3QoJ1NpbXBsZSB2dGwgcmV0dXJucyBjb3JyZWN0bHknLCAoKSA9PiB7XG4gIGNvbnN0IHZ0bCA9ICckdXRpbHMudG9Kc29uKHtcInRlc3RcIjogdHJ1ZX0pJztcbiAgY29uc3QgcGFyc2VyID0gbmV3IFBhcnNlcih2dGwpO1xuICBjb25zdCByZXN1bHQgPSBwYXJzZXIucmVzb2x2ZSh7fSk7XG4gIGV4cGVjdChyZXN1bHQpLnRvQmUoSlNPTi5zdHJpbmdpZnkoeyB0ZXN0OiB0cnVlIH0pKTtcbn0pO1xuIl19 | ||
test('resolve', () => { | ||
const vtl = '$utils.toJson({"test": true})'; | ||
const parser = new index_1.default(vtl); | ||
const result = parser.resolveParse({}); | ||
expect(result.test).toBe(true); | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXgudGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0cy9pbmRleC50ZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEscURBQThCO0FBRTlCLElBQUksQ0FBQyw4QkFBOEIsRUFBRSxHQUFHLEVBQUU7SUFDeEMsTUFBTSxHQUFHLEdBQUcsK0JBQStCLENBQUM7SUFDNUMsTUFBTSxNQUFNLEdBQUcsSUFBSSxlQUFNLENBQUMsR0FBRyxDQUFDLENBQUM7SUFDL0IsTUFBTSxNQ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cGFyc2VyID0gbmV3IFBhcnNlcih2dGwpO1xuICBjb25zdCByZXN1bHQgPSBwYXJzZXIucmVzb2x2ZVBhcnNlKHt9KSBhcyB7IHRlc3Q6IEJvb2xlYW4gfTtcbiAgZXhwZWN0KHJlc3VsdC50ZXN0KS50b0JlKHRydWUpO1xufSk7XG4iXX0= |
{ | ||
"name": "appsync-template-tester", | ||
"description": "Test appsync VTL resolvers, with popular frameworks such as Jest", | ||
"description": "Unit test AppSync VTL resolvers, with popular frameworks such as Jest", | ||
"keywords": [ | ||
@@ -12,2 +12,3 @@ "appsync", | ||
"vtl", | ||
"unit", | ||
"test", | ||
@@ -24,3 +25,3 @@ "tester", | ||
"license": "MIT", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"main": "dist/index.js", | ||
@@ -27,0 +28,0 @@ "scripts": { |
@@ -8,2 +8,4 @@ # appsync-template-tester | ||
Unit test AppSync VTL resolvers, with popular frameworks such as Jest. | ||
## Use | ||
@@ -39,3 +41,4 @@ | ||
const response = parser.resolve(context); | ||
// parser.resolve() returns a string and parser.resolveParse returns the string run through JSON.parse() | ||
const response = parser.resolveParse(context); | ||
@@ -42,0 +45,0 @@ // For convenience, the response is returned as a JS object rather than JSON |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70196
655
58