-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathspread.js
More file actions
executable file
·63 lines (51 loc) · 1.55 KB
/
spread.js
File metadata and controls
executable file
·63 lines (51 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* Created by Aamod Pisat on 09-06-2017.
*/
'use strict';
/*
* Module Dependencies.
*/
const Contentstack = require('../../dist/node/contentstack.js');
const init = require('../config.js');
let Stack;
describe('Contentstack Asset Tests', () => {
// Initialize the Contentstack Stack Instance
beforeAll(() => {
return new Promise((resolve) => {
Stack = Contentstack.Stack(init.stack);
Stack.setHost(init.host);
setTimeout(resolve, 1000);
});
});
test('assets as first argument', async () => {
const Query = Stack.Assets().Query();
const field = 'updated_at';
const result = await Query.limit(1).toJSON().find();
const assets = result[0]; // Using array destructuring
expect(assets.length).toBeTruthy();
if (assets && assets.length) {
let prev = assets[0][field];
const _assets = assets.every((asset) => {
prev = asset[field];
return asset[field] <= prev;
});
expect(_assets).toBe(true);
}
});
test('with assets and count argument', async () => {
const Query = Stack.Assets().Query();
const field = 'updated_at';
const result = await Query.includeCount().toJSON().find();
const [assets, count] = result; // Using array destructuring
expect(assets.length).toBeTruthy();
expect(count).toBeTruthy();
if (assets && assets.length) {
let prev = assets[0][field];
const _assets = assets.every((asset) => {
prev = asset[field];
return asset[field] <= prev;
});
expect(_assets).toBe(true);
}
});
});