Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abumq committed Jul 24, 2023
1 parent cd3a595 commit d034390
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
32 changes: 2 additions & 30 deletions src/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,37 +163,9 @@ const createObject = (obj, depth, currentKey, opts = {}) => {
* Create JSON from promises without extracting functions or multiple await
*
* This can also create special JSON with spreaded values instead of keyed values.
* This function is used alongside {@link spread} function
* ```js
* const props = jjson({
* [spread()]: buildUserDetails(),
* })
* ```
*
* This will result in:
* ```
* {
* id: 123,
* username: 'abumq'
* }
* ```
* whereas if we were to use usual `json()`
* ```js
* const props = json({
* user: buildUserDetails(),
* })
* ```
* that would result in
* ```
* {
* user: {
* id: 123,
* username: 'abumq'
* }
* }
* ```
* (see [spread operator](https://github.com/abumq/airsync#spread-operator))
* @param {*} val Object or Array
* @param {*} opts AirSync options. See https://github.com/abumq/airsync/tree/main#options
* @param {*} opts AirSync options. See [options](https://github.com/abumq/airsync#options)
* @returns Resulting JSON
*/
const json = (val, opts = {}) => {
Expand Down
11 changes: 9 additions & 2 deletions tests/spread.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
const assert = require('assert');
const airsync = require('../src');

const { queryPerson, queryProfile } = require('./utils');

describe('When we have JSON', async () => {
const RACE_NUMBERS = 100;

const logger = {
startTime: console.log,
endTime: console.log,
}

describe('When we have JSON with spread()', async () => {

const buildProps = () => {

Expand All @@ -19,6 +25,7 @@ describe('When we have JSON', async () => {
}

const props = await buildProps();
// console.log(props)

it('the JSON correctly spreads the properties', () => {
assert.equal(props.name, 'John');
Expand Down

0 comments on commit d034390

Please sign in to comment.