Skip to content

Commit 97ec3d7

Browse files
committed
fix(test): Fix test and linting
1 parent a67ff1d commit 97ec3d7

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

lib/get/get-outdated-destination-content.js

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,36 @@ const BATCH_CHAR_LIMIT = 1990
1010
* Only the supplied entry/asset IDs will be retrieved. All contentTypes
1111
* and Locales will be retrieved.
1212
*/
13-
export default function getOutdatedDestinationContent ({
14-
managementClient,
15-
spaceId,
16-
entryIds = [],
17-
assetIds = [],
18-
webhookIds = [],
19-
skipContentModel,
20-
skipContent
21-
}) {
13+
export default function getOutdatedDestinationContent ({managementClient, spaceId, entryIds = [], assetIds = [], webhookIds = [], skipContentModel, skipContent}) {
2214
log.info('Checking if destination space already has any content and retrieving it')
2315

2416
return managementClient.getSpace(spaceId)
2517
.then((space) => {
26-
return Promise.props({
27-
contentTypes: skipContentModel ? Promise.resolve([]) : space.getContentTypes().then(extractItems),
28-
entries: skipContent ? Promise.resolve([]) : batchedIdQuery(space, 'getEntries', entryIds),
29-
assets: skipContent ? Promise.resolve([]) : batchedIdQuery(space, 'getAssets', assetIds),
30-
locales: skipContentModel ? Promise.resolve([]) : space.getLocales().then(extractItems),
31-
webhooks: []
32-
}) }, (err) => {
33-
log.error(`
18+
return Promise.props({
19+
contentTypes: skipContentModel ? Promise.resolve([]) : space.getContentTypes().then(extractItems),
20+
entries: skipContent ? Promise.resolve([]) : batchedIdQuery(space, 'getEntries', entryIds),
21+
assets: skipContent ? Promise.resolve([]) : batchedIdQuery(space, 'getAssets', assetIds),
22+
locales: skipContentModel ? Promise.resolve([]) : space.getLocales().then(extractItems),
23+
webhooks: []
24+
}) }, (err) => {
25+
log.error(`
3426
The destination space was not found. This can happen for multiple reasons:
3527
- If you haven't yet, you should create your space manually.
3628
- If your destination space is in another organization, and your user from the source space does not have access to it, you'll need to specify separate sourceManagementToken and destinationManagementToken
3729
3830
Full error details below.
3931
`)
40-
throw err
41-
})
32+
throw err
33+
})
4234
}
4335

4436
function batchedIdQuery (space, method, ids) {
4537
return Promise.reduce(getIdBatches(ids), (fullResponse, batch) => {
4638
return space[method]({'sys.id[in]': batch})
47-
.then((response) => {
48-
fullResponse = fullResponse.concat(response.items)
49-
return fullResponse
50-
})
39+
.then((response) => {
40+
fullResponse = fullResponse.concat(response.items)
41+
return fullResponse
42+
})
5143
}, [])
5244
}
5345

test/get/get-source-space-via-sync-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function setup () {
1313
sync: sinon.stub().returns(Promise.resolve({
1414
entries: [{sys: {type: 'Entry'}}],
1515
assets: [{sys: {type: 'Asset'}}],
16+
webhooks: [],
1617
deletedEntries: [{sys: {type: 'DeletedEntry'}}],
1718
deletedAssets: [{sys: {type: 'DeletedAsset'}}],
1819
nextSyncToken: 'token'
@@ -35,6 +36,7 @@ function setup () {
3536
const preparedResponse = {
3637
entries: [{sys: {type: 'Entry'}}],
3738
assets: [{sys: {type: 'Asset'}}],
39+
webhooks: [],
3840
deletedEntries: [{sys: {type: 'DeletedEntry'}}],
3941
deletedAssets: [{sys: {type: 'DeletedAsset'}}],
4042
contentTypes: [{sys: {type: 'ContentType'}}],

0 commit comments

Comments
 (0)