ellipsis-api
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -245,2 +245,40 @@ "use strict"; | ||
it("handles variables passed in a JS object", () => { | ||
expect.hasAssertions(); | ||
const query = "{ foo { bar } }"; | ||
const variables = { key1: "something", key2: { key3: "something else" } }; | ||
return storageApi.query({ query: query, variables: variables }).then(data => { | ||
const form = data.body.form; | ||
const expectedForm = { | ||
query: query, | ||
operationName: undefined, | ||
variables: JSON.stringify(variables), | ||
token: ellipsis.token | ||
}; | ||
expect(form).toEqual(expectedForm); | ||
expect(data.url).toEqual(storageApi.url()) | ||
}); | ||
}); | ||
it("handles variables passed in a string", () => { | ||
expect.hasAssertions(); | ||
const query = "{ foo { bar } }"; | ||
const variables = '{ "key1": "something", "key2": { "key3": "something else" } }'; | ||
return storageApi.query({ query: query, variables: variables }).then(data => { | ||
const form = data.body.form; | ||
const expectedForm = { | ||
query: query, | ||
operationName: undefined, | ||
variables: variables, | ||
token: ellipsis.token | ||
}; | ||
expect(form).toEqual(expectedForm); | ||
expect(data.url).toEqual(storageApi.url()) | ||
}); | ||
}); | ||
it("complains if no query", () => { | ||
@@ -247,0 +285,0 @@ |
12
index.js
@@ -195,2 +195,12 @@ const request = require('request'); | ||
variablesStringFor(v) { | ||
if (typeof v === 'object') { | ||
return JSON.stringify(v); | ||
} else if (v && typeof v.toString === 'function') { | ||
return v.toString(); | ||
} else { | ||
return v; | ||
} | ||
} | ||
query(options) { | ||
@@ -202,3 +212,3 @@ return new Promise((resolve, reject) => { | ||
operationName: options.operationName, | ||
variables: options.variables, | ||
variables: this.variablesStringFor(options.variables), | ||
token: this.token() | ||
@@ -205,0 +215,0 @@ }; |
{ | ||
"name": "ellipsis-api", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Interact with Ellipsis skills & actions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
16077
451