Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sencrop-js-api-client

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sencrop-js-api-client - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

.prettierrc.js

20

.eslintrc.js

@@ -6,17 +6,21 @@

'use strict';
module.exports = {
extends: 'eslint-config-simplifield/lib/backend',
extends: 'eslint:recommended',
parserOptions: {
sourceType: 'script',
modules: true,
sourceType: 'module',
ecmaVersion: 8,
ecmaFeatures: {
experimentalObjectRestSpread: true,
},
},
globals: {
expect: true,
env: {
es6: true,
node: true,
jest: true,
mocha: true,
},
plugins: ['prettier'],
rules: {
'no-magic-numbers': 0,
'prettier/prettier': 'error',
},
};

42

.readme/API.md

@@ -42,2 +42,3 @@ # API

* [~getUserDevices(parameters, options)](#module_API..getUserDevices) ⇒ <code>Object</code>
* [~postUserDevice(parameters, options)](#module_API..postUserDevice) ⇒ <code>Object</code>
* [~getUserDevice(parameters, options)](#module_API..getUserDevice) ⇒ <code>Object</code>

@@ -72,2 +73,3 @@ * [~putUserDevice(parameters, options)](#module_API..putUserDevice) ⇒ <code>Object</code>

* [~postOrganisation(parameters, options)](#module_API..postOrganisation) ⇒ <code>Object</code>
* [~putOrganisation(parameters, options)](#module_API..putOrganisation) ⇒ <code>Object</code>

@@ -420,2 +422,3 @@ <a name="module_API..getPing"></a>

| parameters.compute | <code>boolean</code> | Wether the aggregations should be computed, |
| parameters.patched | <code>boolean</code> | Wether you want to get only original data or eventually patched ones to avoid holes., |
| parameters.authorization | <code>string</code> | Authorization with Bearer mecanism |

@@ -565,7 +568,26 @@ | options | <code>Object</code> | Options to override Axios request configuration |

| parameters.userId | <code>number</code> | The user id, |
| parameters.authorization | <code>string</code> | Authorization with Bearer mecanism, |
| parameters.date | <code>string</code> | The status date, |
| parameters.measures | <code>array</code> | The measures to read |
| parameters.measures | <code>array</code> | The measures to read, |
| parameters.patched | <code>boolean</code> | Wether you want to get only original data or eventually patched ones to avoid holes., |
| parameters.limit | <code>number</code> | The number of items to retrieve, |
| parameters.start | <code>number</code> | The index in results, |
| parameters.authorization | <code>string</code> | Authorization with Bearer mecanism |
| options | <code>Object</code> | Options to override Axios request configuration |
<a name="module_API..postUserDevice"></a>
### API~postUserDevice(parameters, options) ⇒ <code>Object</code>
Setup a user's device.
**Kind**: inner method of [<code>API</code>](#module_API)
**Returns**: <code>Object</code> - The HTTP response
| Param | Type | Description |
| --- | --- | --- |
| parameters | <code>Object</code> | The parameters to provide (destructured) |
| parameters.userId | <code>number</code> | The user id, |
| parameters.authorization | <code>string</code> | Authorization with Bearer mecanism, |
| parameters.body | <code>object</code> | The user device activation couple |
| options | <code>Object</code> | Options to override Axios request configuration |
<a name="module_API..getUserDevice"></a>

@@ -1070,1 +1092,17 @@

<a name="module_API..putOrganisation"></a>
### API~putOrganisation(parameters, options) ⇒ <code>Object</code>
Update an organisation.
**Kind**: inner method of [<code>API</code>](#module_API)
**Returns**: <code>Object</code> - The HTTP response
| Param | Type | Description |
| --- | --- | --- |
| parameters | <code>Object</code> | The parameters to provide (destructured) |
| parameters.organisationId | <code>number</code> | The organisation id, |
| parameters.body | <code>object</code> | The modified organisation, |
| parameters.authorization | <code>string</code> | Authorization with Bearer mecanism |
| options | <code>Object</code> | Options to override Axios request configuration |

@@ -23,5 +23,5 @@ /* eslint no-console:0 */

flattenSwagger(require('../src/swagger.api.json'))
.then((API) => {
const operations = getSwaggerOperations(API);
const content = `
.then(API => {
const operations = getSwaggerOperations(API);
const content = `
// WARNING: This file is automatically generated

@@ -40,26 +40,25 @@ // do not change it in place it would be overriden

/**
* ${ API.info.description }
* ${API.info.description}
* @module API
* @version ${ API.info.version }
* @version ${API.info.version}
*/
const API = {
${ operations.map(({ operationId }) => operationId).join(',\n ') },
${operations.map(({ operationId }) => operationId).join(',\n ')},
};
${ operations.map((operation) => {
const { path, method, operationId, parameters } = operation;
${operations
.map(operation => {
const { path, method, operationId, parameters } = operation;
return `
return `
/**
* ${operation.summary}
* @param {Object} parameters
* The parameters to provide (destructured)${
(parameters || []).map(parameter => `
* The parameters to provide (destructured)${(parameters || []).map(
parameter => `
* @param {${
parameter.schema ?
parameter.schema.type :
parameter.type
parameter.schema ? parameter.schema.type : parameter.type
}} parameters.${camelCase(parameter.name)}
* ${ parameter.description }`)
}
* ${parameter.description}`
)}
* @param {Object} options

@@ -70,41 +69,46 @@ * Options to override Axios request configuration

*/
function ${ operationId }({
_,${ (parameters || []).map((parameter) => {
const variableName = camelCase(parameter.name);
function ${operationId}(${
parameters && parameters.length
? `{ ${parameters
.map(parameter => {
const variableName = camelCase(parameter.name);
return `\n ${ variableName },`;
}).join('') }
} = {}, options) {
const method = '${ method }';
let urlParts = [${
path.split('/')
return `\n ${variableName},`;
})
.join('')}} = {}`
: '_'
}, options) {
const method = '${method}';
let urlParts = [${path
.split('/')
.filter(identity => identity)
.map((part) => {
const result = (/^{([a-z0-9]+)}$/ig).exec(part);
.map(part => {
const result = /^{([a-z0-9]+)}$/gi.exec(part);
if(result) {
if (result) {
return `
${ camelCase(result[1]) },`;
${camelCase(result[1])},`;
}
return `
'${ part }',`;
}).join('')}
'${part}',`;
})
.join('')}
];
let headers = {${
(parameters || [])
.filter(p => 'header' === p.in)
.map(parameter => `
${ parameter.name }: ${ camelCase(parameter.name) },`
).join('')}
let headers = {${(parameters || [])
.filter(p => 'header' === p.in)
.map(
parameter => `
${parameter.name}: ${camelCase(parameter.name)},`
)
.join('')}
};
let qs = cleanQuery({${
(parameters || [])
.filter(p => 'query' === p.in)
.map(parameter => `
${ parameter.name }: ${ camelCase(parameter.name)}${
parameter.ordered ?
'.sort(sortMultipleQuery)' :
''
},`
).join('')}
let qs = cleanQuery({${(parameters || [])
.filter(p => 'query' === p.in)
.map(
parameter => `
${parameter.name}: ${camelCase(parameter.name)}${
parameter.ordered ? '.sort(sortMultipleQuery)' : ''
},`
)
.join('')}
});

@@ -115,15 +119,10 @@ let data = ${

// sent. Generalize it.
(parameters || [])
.filter(p => 'body' === p.in)[0] ?
camelCase(
(parameters || [])
.filter(p => 'body' === p.in)[0].name
) :
'{}.undef'
(parameters || []).filter(p => 'body' === p.in)[0]
? camelCase((parameters || []).filter(p => 'body' === p.in)[0].name)
: '{}.undef'
};
return axios(Object.assign({
baseURL: '${ API.schemes[0] || 'https'}://${
API.host + (API.basePath || '')
}',
baseURL: '${API.schemes[0] || 'https'}://${API.host +
(API.basePath || '')}',
paramsSerializer: querystring.stringify.bind(querystring),

@@ -138,3 +137,4 @@ validateStatus: status => 200 <= status && 300 > status,

}`;
}).join('\n') }
})
.join('\n')}

@@ -144,15 +144,15 @@ module.exports = API;

return new Promise((resolve, reject) => {
fs.writeFile('src/index.js', content, (err) => {
if(err) {
reject(err);
return;
}
resolve();
return new Promise((resolve, reject) => {
fs.writeFile('src/index.js', content, err => {
if (err) {
reject(err);
return;
}
resolve();
});
});
})
.catch(err => {
console.error(err.stack);
process.exit(1);
});
})
.catch((err) => {
console.error(err.stack);
process.exit(1);
});

@@ -5,19 +5,15 @@ 'use strict';

const path = require('path');
const {
getSwaggerOperations,
} = require('swagger-http-router/src/utils');
const { getSwaggerOperations } = require('swagger-http-router/src/utils');
const API = require(path.join(
process.cwd(),
process.argv[2]
));
const API = require(path.join(process.cwd(), process.argv[2]));
const operations = getSwaggerOperations(API);
API.paths = operations.reduce((paths, operation) => {
if(operation.tags && operation.tags.includes('private')) {
if (operation.tags && operation.tags.includes('private')) {
return paths;
}
API.paths[operation.path][operation.method].tags =
(operation.tags || []).filter(t => !(t.startsWith('memx') || t.startsWith('tx')));
API.paths[operation.path][operation.method].tags = (
operation.tags || []
).filter(t => !(t.startsWith('memx') || t.startsWith('tx')));

@@ -31,5 +27,5 @@ paths[operation.path] = paths[operation.path] || {};

fs.writeFileSync(path.join(
__dirname,
'../src/swagger.api.json'
), JSON.stringify(API, null, 2));
fs.writeFileSync(
path.join(__dirname, '../src/swagger.api.json'),
JSON.stringify(API, null, 2)
);

@@ -0,1 +1,16 @@

<a name="1.3.1"></a>
## [1.3.1](https://github.com/sencrop/sencrop-js-api-client/compare/v1.3.0...v1.3.1) (2018-02-23)
### Bug Fixes
* **Swagger:** Fix the base url ([95f2eb9](https://github.com/sencrop/sencrop-js-api-client/commit/95f2eb9))
### Features
* **Swagger:** Update the Swagger file to the latest API version ([26a90b3](https://github.com/sencrop/sencrop-js-api-client/commit/26a90b3))
<a name="1.3.0"></a>

@@ -2,0 +17,0 @@ # [1.3.0](https://github.com/sencrop/sencrop-js-api-client/compare/v1.2.0...v1.3.0) (2018-01-24)

{
"name": "sencrop-js-api-client",
"version": "1.3.0",
"version": "1.3.1",
"description": "The Sencrop JavaScript API client",

@@ -12,3 +12,4 @@ "main": "dist/src/index.js",

"jsdocs",
"oss"
"oss",
"eslint"
],

@@ -22,3 +23,3 @@ "data": {

"architecture": "jsarch src/**/*.js bin/*.js test/*.js > ARCHITECTURE.md",
"build": "node bin/build.js",
"build": "node bin/build.js && npm run prettier",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",

@@ -32,4 +33,5 @@ "cli": "env NODE_ENV=${NODE_ENV:-cli}",

"lint": "eslint src/**/*.js bin/*.js test/*.js",
"metapak": "metapak || exit 0",
"metapak": "metapak",
"postinstall": "npm run metapak --silent",
"prettier": "prettier --write src/**/*.js bin/*.js test/*.js",
"preversion": "npm run compile && npm run lint && npm t",

@@ -62,11 +64,11 @@ "test": "npm run compile && jest --config=.jest.config.js && karma start karma.conf.js",

"commitizen": "^2.9.6",
"conventional-changelog-cli": "^1.2.0",
"cz-conventional-changelog": "^2.0.0",
"eslint": "3.16.0",
"eslint-config-simplifield": "4.1.1",
"conventional-changelog-cli": "^1.3.8",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^4.16.0",
"eslint-plugin-prettier": "^2.5.0",
"istanbul": "0.4.5",
"jasmine-core": "^2.7.0",
"jest": "20.0.4",
"jsarch": "1.2.1",
"jsdoc-to-markdown": "^3.0.0",
"jsarch": "1.2.7",
"jsdoc-to-markdown": "^4.0.1",
"karma": "^1.7.0",

@@ -77,6 +79,7 @@ "karma-browserify": "^5.1.1",

"karma-jasmine": "^1.1.0",
"metapak": "0.0.21",
"metapak-sencrop": "2.0.0",
"metapak": "1.0.2",
"metapak-sencrop": "4.1.0",
"moxios": "^0.4.0",
"nock": "^9.0.14",
"prettier": "^1.10.2",
"sinon": "2.3.8",

@@ -83,0 +86,0 @@ "swagger-http-router": "^0.1.0",

@@ -88,2 +88,3 @@ <!--

* [~getUserDevices(parameters, options)](#module_API..getUserDevices) ⇒ <code>Object</code>
* [~postUserDevice(parameters, options)](#module_API..postUserDevice) ⇒ <code>Object</code>
* [~getUserDevice(parameters, options)](#module_API..getUserDevice) ⇒ <code>Object</code>

@@ -118,2 +119,3 @@ * [~putUserDevice(parameters, options)](#module_API..putUserDevice) ⇒ <code>Object</code>

* [~postOrganisation(parameters, options)](#module_API..postOrganisation) ⇒ <code>Object</code>
* [~putOrganisation(parameters, options)](#module_API..putOrganisation) ⇒ <code>Object</code>

@@ -466,2 +468,3 @@ <a name="module_API..getPing"></a>

| parameters.compute | <code>boolean</code> | Wether the aggregations should be computed, |
| parameters.patched | <code>boolean</code> | Wether you want to get only original data or eventually patched ones to avoid holes., |
| parameters.authorization | <code>string</code> | Authorization with Bearer mecanism |

@@ -611,7 +614,26 @@ | options | <code>Object</code> | Options to override Axios request configuration |

| parameters.userId | <code>number</code> | The user id, |
| parameters.authorization | <code>string</code> | Authorization with Bearer mecanism, |
| parameters.date | <code>string</code> | The status date, |
| parameters.measures | <code>array</code> | The measures to read |
| parameters.measures | <code>array</code> | The measures to read, |
| parameters.patched | <code>boolean</code> | Wether you want to get only original data or eventually patched ones to avoid holes., |
| parameters.limit | <code>number</code> | The number of items to retrieve, |
| parameters.start | <code>number</code> | The index in results, |
| parameters.authorization | <code>string</code> | Authorization with Bearer mecanism |
| options | <code>Object</code> | Options to override Axios request configuration |
<a name="module_API..postUserDevice"></a>
### API~postUserDevice(parameters, options) ⇒ <code>Object</code>
Setup a user's device.
**Kind**: inner method of [<code>API</code>](#module_API)
**Returns**: <code>Object</code> - The HTTP response
| Param | Type | Description |
| --- | --- | --- |
| parameters | <code>Object</code> | The parameters to provide (destructured) |
| parameters.userId | <code>number</code> | The user id, |
| parameters.authorization | <code>string</code> | Authorization with Bearer mecanism, |
| parameters.body | <code>object</code> | The user device activation couple |
| options | <code>Object</code> | Options to override Axios request configuration |
<a name="module_API..getUserDevice"></a>

@@ -1116,4 +1138,20 @@

<a name="module_API..putOrganisation"></a>
### API~putOrganisation(parameters, options) ⇒ <code>Object</code>
Update an organisation.
**Kind**: inner method of [<code>API</code>](#module_API)
**Returns**: <code>Object</code> - The HTTP response
| Param | Type | Description |
| --- | --- | --- |
| parameters | <code>Object</code> | The parameters to provide (destructured) |
| parameters.organisationId | <code>number</code> | The organisation id, |
| parameters.body | <code>object</code> | The modified organisation, |
| parameters.authorization | <code>string</code> | Authorization with Bearer mecanism |
| options | <code>Object</code> | Options to override Axios request configuration |
# License
[MIT](https://github.com/sencrop/sencrop-js-api-client/blob/master/LICENSE.md)

@@ -16,24 +16,29 @@ 'use strict';

})
.get('/v1/ping')
.reply(200, {
pong: 'pong',
}, [
'content-type',
'application/json',
'Transaction-Id',
'11',
'Date',
'Thu, 27 Jul 2017 14:23:57 GMT',
'Connection',
'close',
'Transfer-Encoding',
'chunked',
]);
.get('/v1/ping')
.reply(
200,
{
pong: 'pong',
},
[
'content-type',
'application/json',
'Transaction-Id',
'11',
'Date',
'Thu, 27 Jul 2017 14:23:57 GMT',
'Connection',
'close',
'Transfer-Encoding',
'chunked',
]
);
return API.getPing()
.then(response => expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toMatchSnapshot());
return API.getPing().then(response =>
expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toMatchSnapshot()
);
});

@@ -47,65 +52,69 @@ });

})
.get('/v1/users/902/devices/1B28C5/statistics')
.query({
startDate: '1404172800000',
endDate: '1500595200000',
measures: ['RH_AIR_H1', 'TEMP_AIR_H1'],
})
.reply(200, {
models: {
7: {
id: 7,
contents: {
name: 'Raincrop',
externalDiameter: 0.206,
conception: 'France - Lille',
manufacturing: 'Europe-France',
calibration: 'Ok',
weight: 3.5,
.get('/v1/users/902/devices/1B28C5/statistics')
.query({
startDate: '1404172800000',
endDate: '1500595200000',
measures: ['RH_AIR_H1', 'TEMP_AIR_H1'],
})
.reply(
200,
{
models: {
7: {
id: 7,
contents: {
name: 'Raincrop',
externalDiameter: 0.206,
conception: 'France - Lille',
manufacturing: 'Europe-France',
calibration: 'Ok',
weight: 3.5,
},
},
},
},
},
devices: {
'1B28C5': {
id: '1B28C5',
contents: {
serial: '1B28C5',
identification: 'RC000117',
name: 'RC000117',
date_start: 1494799200,
date_stop: 2147483647,
role: 'owner',
devices: {
'1B28C5': {
id: '1B28C5',
contents: {
serial: '1B28C5',
identification: 'RC000117',
name: 'RC000117',
date_start: 1494799200,
date_stop: 2147483647,
role: 'owner',
},
},
},
entry: '1B28C5',
measures: {
interval: 'month',
data: [
{
key_as_string: '1404165600000',
key: 1404165600000,
doc_count: 0,
RH_AIR_H1: {},
},
{
key_as_string: '1406844000000',
key: 1406844000000,
doc_count: 0,
RH_AIR_H1: {},
},
],
},
},
},
entry: '1B28C5',
measures: {
interval: 'month',
data: [
{
key_as_string: '1404165600000',
key: 1404165600000,
doc_count: 0,
RH_AIR_H1: {},
},
{
key_as_string: '1406844000000',
key: 1406844000000,
doc_count: 0,
RH_AIR_H1: {},
},
],
},
}, [
'content-type',
'application/json',
'Transaction-Id',
'12',
'Date',
'Thu, 27 Jul 2017 14:23:57 GMT',
'Connection',
'close',
'Transfer-Encoding',
'chunked',
]);
[
'content-type',
'application/json',
'Transaction-Id',
'12',
'Date',
'Thu, 27 Jul 2017 14:23:57 GMT',
'Connection',
'close',
'Transfer-Encoding',
'chunked',
]
);

@@ -119,8 +128,9 @@ return API.getUserDeviceStatistics({

measures: ['RH_AIR_H1', 'TEMP_AIR_H1'],
})
.then(response => expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toMatchSnapshot());
}).then(response =>
expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toMatchSnapshot()
);
});

@@ -134,34 +144,38 @@ });

})
.put('/v1/users/902/devices/1B28C5', {
contents: {
serial: '1B28C5',
identification: 'RC000117',
name: 'RC000117',
date_start: 1494799200,
date_stop: 2147483647,
role: 'owner',
},
})
.reply(201, {
id: '1B28C5',
contents: {
serial: '1B28C5',
identification: 'RC000117',
name: 'RC000117',
date_start: 1494799200,
date_stop: 2147483647,
role: 'owner',
},
}, [
'content-type',
'application/json',
'Transaction-Id',
'13',
'Date',
'Thu, 27 Jul 2017 14:23:57 GMT',
'Connection',
'close',
'Transfer-Encoding',
'chunked',
]);
.put('/v1/users/902/devices/1B28C5', {
contents: {
serial: '1B28C5',
identification: 'RC000117',
name: 'RC000117',
date_start: 1494799200,
date_stop: 2147483647,
role: 'owner',
},
})
.reply(
201,
{
id: '1B28C5',
contents: {
serial: '1B28C5',
identification: 'RC000117',
name: 'RC000117',
date_start: 1494799200,
date_stop: 2147483647,
role: 'owner',
},
},
[
'content-type',
'application/json',
'Transaction-Id',
'13',
'Date',
'Thu, 27 Jul 2017 14:23:57 GMT',
'Connection',
'close',
'Transfer-Encoding',
'chunked',
]
);

@@ -182,10 +196,11 @@ return API.putUserDevice({

},
})
.then(response => expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toMatchSnapshot());
}).then(response =>
expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toMatchSnapshot()
);
});
});
});

@@ -11,3 +11,3 @@ 'use strict';

.filter(key => 'undefined' !== typeof query[key])
.filter(key => (!(query[key] instanceof Array)) || 0 !== query[key].length)
.filter(key => !(query[key] instanceof Array) || 0 !== query[key].length)
.reduce((newQuery, key) => {

@@ -14,0 +14,0 @@ newQuery[key] = query[key];

@@ -7,3 +7,2 @@ 'use strict';

describe('API', () => {
beforeEach(() => {

@@ -18,22 +17,21 @@ moxios.install();

describe('for simple URI', () => {
it('should work', (done) => {
const promise = API.getPing({})
.then(response => expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toEqual({
status: 200,
headers: {}.undef,
body: {
pong: 'pong',
},
}));
it('should work', done => {
const promise = API.getPing({}).then(response =>
expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toEqual({
status: 200,
headers: {}.undef,
body: {
pong: 'pong',
},
})
);
moxios.wait(() => {
Promise.all([
promise,
moxios.requests.mostRecent()
.respondWith({
moxios.requests.mostRecent().respondWith({
status: 200,

@@ -45,4 +43,4 @@ response: {

])
.then(done)
.catch(done.fail);
.then(done)
.catch(done.fail);
});

@@ -53,3 +51,3 @@ });

describe('with Token/URI params and query strings', () => {
it('should work', (done) => {
it('should work', done => {
const promise = API.getUserDeviceStatistics({

@@ -62,64 +60,63 @@ userId: 902,

measures: ['RH_AIR_H1', 'TEMP_AIR_H1'],
})
.then(response => expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toEqual({
status: 200,
headers: {}.undef,
body: {
models: {
7: {
id: 7,
contents: {
name: 'Raincrop',
externalDiameter: 0.206,
conception: 'France - Lille',
manufacturing: 'Europe-France',
calibration: 'Ok',
weight: 3.5,
}).then(response =>
expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toEqual({
status: 200,
headers: {}.undef,
body: {
models: {
7: {
id: 7,
contents: {
name: 'Raincrop',
externalDiameter: 0.206,
conception: 'France - Lille',
manufacturing: 'Europe-France',
calibration: 'Ok',
weight: 3.5,
},
},
},
},
devices: {
'1B28C5': {
id: '1B28C5',
contents: {
serial: '1B28C5',
identification: 'RC000117',
name: 'RC000117',
date_start: 1494799200,
date_stop: 2147483647,
role: 'owner',
devices: {
'1B28C5': {
id: '1B28C5',
contents: {
serial: '1B28C5',
identification: 'RC000117',
name: 'RC000117',
date_start: 1494799200,
date_stop: 2147483647,
role: 'owner',
},
},
},
entry: '1B28C5',
measures: {
interval: 'month',
data: [
{
key_as_string: '1404165600000',
key: 1404165600000,
doc_count: 0,
RH_AIR_H1: {},
},
{
key_as_string: '1406844000000',
key: 1406844000000,
doc_count: 0,
RH_AIR_H1: {},
},
],
},
},
entry: '1B28C5',
measures: {
interval: 'month',
data: [
{
key_as_string: '1404165600000',
key: 1404165600000,
doc_count: 0,
RH_AIR_H1: {},
},
{
key_as_string: '1406844000000',
key: 1406844000000,
doc_count: 0,
RH_AIR_H1: {},
},
],
},
},
}));
})
);
moxios.wait(() => {
Promise.all([
promise,
moxios.requests.mostRecent()
.respondWith({
moxios.requests.mostRecent().respondWith({
status: 200,

@@ -174,4 +171,4 @@ response: {

])
.then(done)
.catch(done.fail);
.then(done)
.catch(done.fail);
});

@@ -182,3 +179,3 @@ });

describe('with a body', () => {
it('should work', (done) => {
it('should work', done => {
const promise = API.putUserDevice({

@@ -198,22 +195,23 @@ userId: 902,

},
})
.then(response => expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toEqual({
status: 201,
headers: {}.undef,
body: {
id: '1B28C5',
contents: {
serial: '1B28C5',
identification: 'RC000117',
name: 'RC000117',
date_start: 1494799200,
date_stop: 2147483647,
role: 'owner',
}).then(response =>
expect({
status: response.status,
headers: response.headers,
body: response.data,
}).toEqual({
status: 201,
headers: {}.undef,
body: {
id: '1B28C5',
contents: {
serial: '1B28C5',
identification: 'RC000117',
name: 'RC000117',
date_start: 1494799200,
date_stop: 2147483647,
role: 'owner',
},
},
},
}));
})
);

@@ -223,4 +221,3 @@ moxios.wait(() => {

promise,
moxios.requests.mostRecent()
.respondWith({
moxios.requests.mostRecent().respondWith({
status: 201,

@@ -240,4 +237,4 @@ response: {

])
.then(done)
.catch(done.fail);
.then(done)
.catch(done.fail);
});

@@ -244,0 +241,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc