@agility/content-fetch 2.0.0-rc1 → 2.0.0-rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/content-fetch",
3
- "version": "2.0.0-rc1",
3
+ "version": "2.0.0-rc2",
4
4
  "description": "JavaScript library for the Agility Fetch API (node and browser)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,17 +34,15 @@
34
34
  ],
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
- "@types/jest": "^29.5.3",
38
37
  "axios": "^0.27.2",
39
- "axios-cache-adapter": "^2.7.3",
40
- "install": "^0.13.0",
41
- "jest": "^29.6.2",
42
- "npm": "^9.8.1",
43
- "ts-jest": "^29.1.1",
44
- "typescript": "^5.1.6"
38
+ "axios-cache-adapter": "^2.7.3"
45
39
  },
46
40
  "devDependencies": {
47
41
  "@types/node": "^18.11.9",
48
- "agility-jsdoc-template": "1.0.3"
42
+ "agility-jsdoc-template": "1.0.3",
43
+ "jest": "^29.6.2",
44
+ "@types/jest": "^29.5.3",
45
+ "ts-jest": "^29.1.1",
46
+ "typescript": "^5.1.6"
49
47
  }
50
- }
48
+ }
@@ -1,50 +0,0 @@
1
- import agilityFetch from '../src/index';
2
-
3
- // Agility Instance = 'Headless Integration Testing' [Dev]
4
- const guid = 'c741222b-1080-45f6-9a7f-982381c5a485';
5
- const apiKeyFetch = 'UnitTestsFetch.2ace650991363fbcffa6776d411d1b0d616b8e3424ce842b81cba7af0039197e';
6
- const apiKeyPreview = 'UnitTestsPreview.69e6bca345ced0b7ca5ab358b351ea5c870790a5945c25d749a865332906b124';
7
-
8
-
9
- export function createApiClient() {
10
- console.log(`Creating API Client for ${guid}`);
11
- var api = agilityFetch.getApi({
12
- guid: guid,
13
- apiKey: apiKeyFetch,
14
- baseUrl: `https://api-dev.aglty.io/${guid}`
15
- });
16
- return api;
17
- }
18
-
19
- export function createApiClientWithNewCdn() {
20
- console.log(`Creating API Client for ${guid}`);
21
- var api = agilityFetch.getApi({
22
- guid: '2b64a4d8-d',
23
- apiKey: 'JSSDK.e27e61f56d4c9b58ab98961aaf86a0d3c544dfe7d0eb385ece42123dad5d1af7'
24
- });
25
- return api;
26
- }
27
-
28
- export function createCachedApiClient() {
29
- console.log(`Creating API Client for ${guid}`);
30
- var api = agilityFetch.getApi({
31
- guid: guid,
32
- apiKey: apiKeyFetch,
33
- caching: {
34
- maxAge: 5 * 60 * 1000 //==5mins
35
- },
36
- baseUrl: `https://api-dev.aglty.io/${guid}`
37
- });
38
- return api;
39
- }
40
-
41
- export function createPreviewApiClient() {
42
- console.log(`Creating API Client for ${guid}`);
43
- var api = agilityFetch.getApi({
44
- guid: guid,
45
- apiKey: apiKeyPreview,
46
- isPreview: true,
47
- baseUrl: `https://api-dev.aglty.io/${guid}`
48
- });
49
- return api;
50
- }
@@ -1,153 +0,0 @@
1
- import agilityFetch from '../src/index';
2
-
3
- //This is a synchronous test
4
- describe('getApi:', function() {
5
-
6
- jest.setTimeout(120000);
7
-
8
- it('should return an api client object with required params', () => {
9
- const api = agilityFetch.getApi({
10
- guid: 'some-guid',
11
- apiKey: 'some-access-token'
12
- });
13
- expect(typeof api).toBe("object");
14
- });
15
-
16
- it('should return an api client object in preview mode', () => {
17
- const api = agilityFetch.getApi({
18
- guid: 'some-guid',
19
- apiKey: 'some-access-token',
20
- isPreview: true
21
- });
22
- expect(api.config.isPreview).toBe(true);
23
- });
24
-
25
- it('should contain method for getContentItem', function(done) {
26
- const api = agilityFetch.getApi({
27
- guid: 'some-guid',
28
- apiKey: 'some-access-token'
29
- });
30
- expect(typeof(api.getContentItem)).toBe("function");
31
- done();
32
- })
33
-
34
- it('should contain method for getContentList', function(done) {
35
- const api = agilityFetch.getApi({
36
- guid: 'some-guid',
37
- apiKey: 'some-access-token'
38
- });
39
- expect(typeof(api.getContentList)).toBe("function");
40
- done();
41
- })
42
-
43
- it('should contain method for getPage', function(done) {
44
- const api = agilityFetch.getApi({
45
- guid: 'some-guid',
46
- apiKey: 'some-access-token'
47
- });
48
- expect(typeof(api.getPage)).toBe("function");
49
- done();
50
- })
51
-
52
- it('should contain method for getSitemapFlat', function(done) {
53
- const api = agilityFetch.getApi({
54
- guid: 'some-guid',
55
- apiKey: 'some-access-token'
56
- });
57
- expect(typeof(api.getSitemapFlat)).toBe("function");
58
- done();
59
- })
60
-
61
- it('should contain method for getSitemapNested', function(done) {
62
- const api = agilityFetch.getApi({
63
- guid: 'some-guid',
64
- apiKey: 'some-access-token'
65
- });
66
- expect(typeof(api.getSitemapNested)).toBe("function");
67
- done();
68
- })
69
-
70
- it('should return an api client with the baseUrl overidden if passed-in correctly as params', function(done) {
71
- const baseUrl = 'https://fake-url.agilitycms.com';
72
- const api = agilityFetch.getApi({
73
- guid: 'some-guid',
74
- apiKey: 'some-access-token',
75
- baseUrl: baseUrl
76
- });
77
- expect(api.config.baseUrl).toBe(baseUrl);
78
- done();
79
- });
80
-
81
- it('should return an api client with new stackpath baseUrl based on canada', function(done) {
82
- const baseUrl = 'https://api-ca.aglty.io/some-guid-c';
83
- const api = agilityFetch.getApi({
84
- guid: 'some-guid-c',
85
- apiKey: 'some-access-token',
86
- baseUrl: null
87
- });
88
- expect(api.config.baseUrl).toBe(baseUrl);
89
- done();
90
- });
91
-
92
- it('should return an api client with new stackpath baseUrl based on usa', function(done) {
93
- const baseUrl = 'https://api.aglty.io/some-guid-u';
94
- const api = agilityFetch.getApi({
95
- guid: 'some-guid-u',
96
- apiKey: 'some-access-token',
97
- baseUrl: null
98
- });
99
- expect(api.config.baseUrl).toBe(baseUrl);
100
- done();
101
- });
102
-
103
- it('should return an api client with new stackpath baseUrl based on dev', function(done) {
104
- const baseUrl = 'https://api-dev.aglty.io/some-guid-d';
105
- const api = agilityFetch.getApi({
106
- guid: 'some-guid-d',
107
- apiKey: 'some-access-token',
108
- baseUrl: null
109
- });
110
- expect(api.config.baseUrl).toBe(baseUrl);
111
- done();
112
- });
113
-
114
- it('should return an api client with legacy stackpath baseUrl', function(done) {
115
- const baseUrl = 'https://some-guid-api.agilitycms.cloud';
116
- const api = agilityFetch.getApi({
117
- guid: 'some-guid',
118
- apiKey: 'some-access-token',
119
- baseUrl: null
120
- });
121
- expect(api.config.baseUrl).toBe(baseUrl);
122
- done();
123
- });
124
-
125
- // TESTING EXCEPTIONS ----------------------------------------------------
126
-
127
- it('should throw an error if guid is not passed-in', () => {
128
- expect(() => {
129
- agilityFetch.getApi({
130
- apiKey: 'some-access-token'
131
- });
132
- }).toThrow(TypeError);
133
- });
134
-
135
- it('should throw an error if apiKey is not passed-in', () => {
136
- expect(() => {
137
- agilityFetch.getApi({
138
- guid: 'some-guid',
139
- });
140
- }).toThrow(TypeError);
141
- });
142
-
143
- it('should throw an error if baseUrl is passed-in and does not start with "https"', () => {
144
- expect(() => {
145
- agilityFetch.getApi({
146
- guid: 'some-guid',
147
- apiKey: 'some-access-token',
148
- baseUrl: 'http://insecuresite.com'
149
- });
150
- }).toThrow(TypeError);
151
- });
152
-
153
- });
@@ -1,103 +0,0 @@
1
- import {
2
- createApiClient,
3
- createPreviewApiClient,
4
- createCachedApiClient,
5
- createApiClientWithNewCdn
6
- } from './apiClients.config';
7
-
8
- /*
9
- This file contains static references to content from the instance configured in the apiClient.config file.
10
- */
11
-
12
- const ref = {
13
- publishedContentItemID: 15,
14
- updatesMadeToPublishedContentItemID: 15
15
- }
16
-
17
- describe('getContentItem:', () => {
18
- jest.setTimeout(120000);
19
-
20
- it('should retrieve a content item in live/fetch mode and only return published content', async () => {
21
- const api = createApiClient();
22
- const contentItem = await api.getContentItem({
23
- contentID: ref.updatesMadeToPublishedContentItemID,
24
- locale: 'en-us'
25
- });
26
- expect(contentItem.contentID).toBe(ref.updatesMadeToPublishedContentItemID);
27
- expect(contentItem.fields.title).not.toMatch(/\[Staging\]/);
28
- });
29
-
30
- it('should retrieve a content item in preview mode and return the latest staging version', async () => {
31
- const api = createPreviewApiClient();
32
- const contentItem = await api.getContentItem({
33
- contentID: ref.updatesMadeToPublishedContentItemID,
34
- locale: 'en-us'
35
- });
36
- expect(contentItem.contentID).toBe(ref.updatesMadeToPublishedContentItemID);
37
- expect(contentItem.fields.title).toMatch(/\[Staging\]/);
38
- });
39
-
40
- it('should retrieve a content item in live/fetch mode, then subsequent requests are returned from cache (memory)', async () => {
41
- const api = createCachedApiClient();
42
- const contentItem = await api.getContentItem({
43
- contentID: ref.updatesMadeToPublishedContentItemID,
44
- locale: 'en-us'
45
- });
46
-
47
- expect(contentItem.contentID).toBe(ref.updatesMadeToPublishedContentItemID);
48
- expect(contentItem.fromCache).toBeFalsy();
49
-
50
- const contentItem2 = await api.getContentItem({
51
- contentID: ref.updatesMadeToPublishedContentItemID,
52
- locale: 'en-us'
53
- });
54
-
55
- expect(contentItem2.contentID).toBe(ref.updatesMadeToPublishedContentItemID);
56
- expect(contentItem2.fromCache).toBeTruthy();
57
- });
58
-
59
- it('should throw error if locale not passed as argument for getContentItem', async () => {
60
- const api = createApiClient();
61
- await expect(api.getContentItem({
62
- contentID: 22
63
- })).rejects.toThrow(TypeError);
64
- });
65
-
66
- it('should expand all content links when expandContentLinks are set to true', async () => {
67
- const api = createApiClient();
68
- const contentItem = await api.getContentItem({
69
- contentID: 65,
70
- locale: 'en-us',
71
- expandAllContentLinks: true
72
- });
73
- expect(Array.isArray(contentItem.fields.posts)).toBe(true);
74
- });
75
-
76
- it('should NOT expand all content links when expandContentLinks are set to false', async () => {
77
- const api = createApiClient();
78
- const contentItem = await api.getContentItem({
79
- contentID: 65,
80
- locale: 'en-us',
81
- expandAllContentLinks: false
82
- });
83
- expect(Array.isArray(contentItem.fields.posts)).toBe(false);
84
- });
85
-
86
- it('should NOT expand all content links when expandContentLinks is not set', async () => {
87
- const api = createApiClient();
88
- const contentItem = await api.getContentItem({
89
- contentID: 65,
90
- locale: 'en-us'
91
- });
92
- expect(Array.isArray(contentItem.fields.posts)).toBe(false);
93
- });
94
-
95
- it('should be able to fetch an item using global cdn site', async () => {
96
- const api = createApiClientWithNewCdn();
97
- const contentItem = await api.getContentItem({
98
- contentID: 4,
99
- locale: 'en-us'
100
- });
101
- expect(contentItem.fields.title).toBe('JS SDK Item - DO NOT DELETE');
102
- });
103
- });
@@ -1,251 +0,0 @@
1
- const {
2
- createApiClient,
3
- createPreviewApiClient,
4
- createCachedApiClient,
5
- createApiClientWithNewCdn,
6
- } = require('./apiClients.config');
7
-
8
- describe('getContentList:', () => {
9
- jest.setTimeout(120000);
10
-
11
- it('should retrieve a content list in live mode', async () => {
12
- const api = createApiClient();
13
- const contentList = await api.getContentList({
14
- referenceName: 'posts',
15
- locale: 'en-us',
16
- });
17
- expect(contentList.items[0].contentID).toBe(16);
18
- expect(contentList.items[3].contentID).toBe(15);
19
- });
20
-
21
- it('should retrieve a content list in preview mode', async () => {
22
- const api = createPreviewApiClient();
23
- const contentList = await api.getContentList({
24
- referenceName: 'posts',
25
- locale: 'en-us',
26
- });
27
- expect(contentList.items[0].contentID).toBe(15);
28
- expect(contentList.items[1].contentID).toBe(16);
29
- });
30
-
31
- it('should throw error if referenceName not passed as argument for getContentList', async () => {
32
- const api = createApiClient();
33
- await expect(
34
- api.getContentList({
35
- someOtherParam: 'posts',
36
- locale: 'en-us',
37
- })
38
- ).rejects.toThrow(TypeError);
39
- });
40
-
41
- it('should throw error if locale param is missing in getContentList', async () => {
42
- const api = createApiClient();
43
- await expect(
44
- api.getContentList({
45
- referenceName: 'posts',
46
- })
47
- ).rejects.toThrow(TypeError);
48
- });
49
-
50
- it('should throw error if take parameter is NOT a number in getContentList', async () => {
51
- const api = createApiClient();
52
- await expect(
53
- api.getContentList({
54
- referenceName: 'posts',
55
- locale: 'en-us',
56
- take: 'ten',
57
- })
58
- ).rejects.toThrow(TypeError);
59
- });
60
-
61
- it('should throw error if take parameter is a number less than 1 in getContentList', async () => {
62
- const api = createApiClient();
63
- await expect(
64
- api.getContentList({
65
- referenceName: 'posts',
66
- locale: 'en-us',
67
- take: 0,
68
- })
69
- ).rejects.toThrow(TypeError);
70
- });
71
-
72
- it('should throw error if take parameter is a number greater than 250 in getContentList', async () => {
73
- const api = createApiClient();
74
- await expect(
75
- api.getContentList({
76
- referenceName: 'posts',
77
- locale: 'en-us',
78
- take: 251,
79
- })
80
- ).rejects.toThrow(TypeError);
81
- });
82
-
83
- it('should throw error if skip parameter is a number less than 0 in getContentList', async () => {
84
- const api = createApiClient();
85
- await expect(
86
- api.getContentList({
87
- referenceName: 'posts',
88
- locale: 'en-us',
89
- skip: -1,
90
- })
91
- ).rejects.toThrow(TypeError);
92
- });
93
-
94
- it('should throw error if skip parameter is NOT a number in getContentList', async () => {
95
- const api = createApiClient();
96
- await expect(
97
- api.getContentList({
98
- referenceName: 'posts',
99
- locale: 'en-us',
100
- skip: 'ten',
101
- })
102
- ).rejects.toThrow(TypeError);
103
- });
104
-
105
- it('should throw error if direction parameter is NOT "asc" or "desc" in getContentList', async () => {
106
- const api = createApiClient();
107
- await expect(
108
- api.getContentList({
109
- referenceName: 'posts',
110
- locale: 'en-us',
111
- sort: 'fields.title',
112
- direction: 'up',
113
- })
114
- ).rejects.toThrow(TypeError);
115
- });
116
-
117
- it('should sort the content list in live mode', async () => {
118
- const api = createApiClient();
119
- const contentList = await api.getContentList({
120
- referenceName: 'posts',
121
- locale: 'en-us',
122
- sort: 'contentID',
123
- });
124
- expect(contentList.items[0].contentID).toBeLessThan(contentList.items[1].contentID);
125
- });
126
-
127
- it('should validate all filters contain property called \'property\'', async () => {
128
- const api = createApiClient();
129
- await expect(
130
- api.getContentList({
131
- referenceName: 'posts',
132
- locale: 'en-us',
133
- filters: [{ operator: api.types.FilterOperators.EQUAL_TO, value: '40' }],
134
- })
135
- ).rejects.toThrow(TypeError);
136
- });
137
-
138
- it('should validate all filters contain property called \'operator\'', async () => {
139
- const api = createApiClient();
140
- await expect(
141
- api.getContentList({
142
- referenceName: 'posts',
143
- locale: 'en-us',
144
- filters: [{ property: 'properties.versionID', value: '40' }],
145
- })
146
- ).rejects.toThrow(TypeError);
147
- });
148
-
149
- it('should validate all filters contain property called \'value\'', async () => {
150
- const api = createApiClient();
151
- await expect(
152
- api.getContentList({
153
- referenceName: 'posts',
154
- locale: 'en-us',
155
- filters: [{ property: 'properties.versionID', operator: api.types.FilterOperators.EQUAL_TO }],
156
- })
157
- ).rejects.toThrow(TypeError);
158
- });
159
-
160
- it('should validate operator property on all filters', async () => {
161
- const api = createApiClient();
162
- await expect(
163
- api.getContentList({
164
- referenceName: 'posts',
165
- locale: 'en-us',
166
- filters: [{ property: 'properties.versionID', operator: 'xx', value: '40' }],
167
- })
168
- ).rejects.toThrow(TypeError);
169
- });
170
-
171
- it('should validate the filtersLogicOperator to be AND or OR', async () => {
172
- const api = createApiClient();
173
- await expect(
174
- api.getContentList({
175
- referenceName: 'posts',
176
- locale: 'en-us',
177
- filtersLogicOperator: 'SOME',
178
- })
179
- ).rejects.toThrow(TypeError);
180
- });
181
-
182
- it('should filter the content list in live mode with OR operator between filters', async () => {
183
- const api = createApiClient();
184
- const contentList = await api.getContentList({
185
- referenceName: 'posts',
186
- locale: 'en-us',
187
- filters: [
188
- { property: 'contentID', operator: api.types.FilterOperators.EQUAL_TO, value: '15' },
189
- { property: 'properties.referenceName', operator: api.types.FilterOperators.LIKE, value: 'posts' },
190
- ],
191
- filtersLogicOperator: api.types.FilterLogicOperators.OR,
192
- });
193
- expect(contentList.items[0].contentID).toBe(16);
194
- expect(contentList.items[3].contentID).toBe(15);
195
- });
196
-
197
- it('should filter the content list in live mode with AND operator between filters', async () => {
198
- const api = createApiClient();
199
- const contentList = await api.getContentList({
200
- referenceName: 'posts',
201
- locale: 'en-us',
202
- filters: [
203
- { property: 'contentID', operator: api.types.FilterOperators.EQUAL_TO, value: '16' },
204
- { property: 'properties.referenceName', operator: api.types.FilterOperators.LIKE, value: 'posts' },
205
- ],
206
- filtersLogicOperator: api.types.FilterLogicOperators.AND,
207
- });
208
- expect(contentList.items[0].contentID).toBe(16);
209
- expect(contentList.items.length).toBe(1);
210
- });
211
-
212
- it('should expand all content links when expandContentLinks are set to true', async () => {
213
- const api = createApiClient();
214
- const contentList = await api.getContentList({
215
- referenceName: 'listwithnestedcontentlink',
216
- locale: 'en-us',
217
- expandAllContentLinks: true,
218
- });
219
- expect(Array.isArray(contentList.items[0].fields.posts)).toBe(true);
220
- });
221
-
222
- it('should NOT expand all content links when expandContentLinks are set to false', async () => {
223
- const api = createApiClient();
224
- const contentList = await api.getContentList({
225
- referenceName: 'listwithnestedcontentlink',
226
- locale: 'en-us',
227
- expandAllContentLinks: false,
228
- });
229
- expect(Array.isArray(contentList.items[0].fields.posts)).toBe(false);
230
- });
231
-
232
- it('should NOT expand all content links when expandContentLinks is not set at all', async () => {
233
- const api = createApiClient();
234
- const contentList = await api.getContentList({
235
- referenceName: 'listwithnestedcontentlink',
236
- locale: 'en-us',
237
- });
238
- expect(Array.isArray(contentList.items[0].fields.posts)).toBe(false);
239
- });
240
-
241
- it('should be able to fetch a list using global cdn site', async () => {
242
- const api = createApiClientWithNewCdn();
243
- const referenceName = 'jssdklist';
244
- const contentList = await api.getContentList({
245
- referenceName: referenceName,
246
- locale: 'en-us',
247
- });
248
- expect(contentList.items[0].properties.referenceName).toBe(referenceName);
249
- });
250
- });
251
-
@@ -1,22 +0,0 @@
1
- import {
2
- createApiClient,
3
- } from './apiClients.config';
4
-
5
-
6
- /*
7
- This file contains static references to content from the instance configured in the apiClient.config file.
8
- */
9
-
10
- /* GET GALLERY *********************************************************/
11
- describe('getGallery:', () => {
12
- jest.setTimeout(120000); // equivalent to this.timeout('120s')
13
-
14
- it('should retrieve a Gallery in live mode', async () => {
15
- const api = createApiClient();
16
- const gallery = await api.getGallery({
17
- galleryID: 1,
18
- });
19
- expect(gallery.galleryID).toBe(1);
20
- });
21
- });
22
-
@@ -1,39 +0,0 @@
1
- // Assuming you have imported createApiClient, createPreviewApiClient, and the necessary dependencies
2
- import { createApiClient, createPreviewApiClient } from './apiClients.config';
3
-
4
- describe('getPage:', () => {
5
- jest.setTimeout(120000); // equivalent to this.timeout('120s')
6
-
7
- it('should retrieve a page in live mode', async () => {
8
- const api = createApiClient();
9
- const page = await api.getPage({
10
- pageID: 2,
11
- locale: 'en-us',
12
- });
13
- console.log(page, 'check this')
14
- expect(page.pageID).toBe(2);
15
- });
16
-
17
-
18
- it('should retrieve a page in preview mode', async () => {
19
- const api = createPreviewApiClient();
20
- const page = await api.getPage({
21
- pageID: 2,
22
- locale: 'en-us',
23
- });
24
- console.log(page, 'check this')
25
- expect(page.pageID).toBe(2);
26
- });
27
-
28
- it('should retrieve a page and expand all content links when expandAllContentLink is set to true', async () => {
29
- const api = createApiClient();
30
- const page = await api.getPage({
31
- pageID: 2,
32
- locale: 'en-us',
33
- expandAllContentLinks: true,
34
- });
35
- expect(Array.isArray(page.zones.MainContentZone[2].item.fields.posts)).toBe(true);
36
- });
37
-
38
-
39
- });
@@ -1,30 +0,0 @@
1
- import { createApiClient, createPreviewApiClient } from './apiClients.config';
2
-
3
- /*
4
- This file contains static references to content from the instance configured in the apiClient.config file.
5
- */
6
-
7
-
8
- /* GET SITEMAP FLAT ***********************************************/
9
- describe('getSitemapFlat:', () => {
10
- jest.setTimeout(120000); // equivalent to this.timeout('120s')
11
-
12
- it('should retrieve a sitemap in a flat format in live mode', async () => {
13
- const api = createApiClient();
14
- const sitemap = await api.getSitemapFlat({
15
- channelName: 'website',
16
- locale: 'en-us',
17
- });
18
- expect(sitemap['/home'].pageID).toBe(2);
19
- });
20
-
21
- it('should retrieve a sitemap in a flat format in preview mode', async () => {
22
- const api = createPreviewApiClient();
23
- const sitemap = await api.getSitemapFlat({
24
- channelName: 'website',
25
- locale: 'en-us',
26
- });
27
- expect(sitemap['/home'].pageID).toBe(2);
28
- });
29
-
30
- });
@@ -1,30 +0,0 @@
1
- import { createApiClient, createPreviewApiClient } from './apiClients.config';
2
-
3
- /*
4
- This file contains static references to content from the instance configured in the apiClient.config file.
5
- */
6
-
7
-
8
- /* GET SITEMAP NESTED **************************************************/
9
- describe('getSitemapNested:', () => {
10
- jest.setTimeout(120000); // equivalent to this.timeout('120s')
11
-
12
- it('should retrieve a sitemap in a nested format in live mode', async () => {
13
- const api = createApiClient();
14
- const sitemap = await api.getSitemapNested({
15
- channelName: 'website',
16
- locale: 'en-us',
17
- });
18
- expect(sitemap[0].pageID).toBe(2);
19
- });
20
-
21
- it('should retrieve a sitemap in a nested format in preview mode', async () => {
22
- const api = createPreviewApiClient();
23
- const sitemap = await api.getSitemapNested({
24
- channelName: 'website',
25
- locale: 'en-us',
26
- });
27
- expect(sitemap[0].pageID).toBe(2);
28
- });
29
-
30
- });
@@ -1,25 +0,0 @@
1
- import { createApiClient } from './apiClients.config';
2
-
3
- /*
4
- This file contains static references to content from the instance configured in the apiClient.config file.
5
- */
6
- describe('getSyncContent:', () => {
7
- jest.setTimeout(120000); // equivalent to this.timeout('120s')
8
-
9
- it('should retrieve the oldest content items and next sync token', async () => {
10
- const api = createApiClient();
11
-
12
- let syncToken = 0;
13
-
14
- //sync from scratch
15
- const syncRet = await api.getSyncContent({
16
- syncToken: syncToken,
17
- pageSize: 100,
18
- locale: 'en-us',
19
- });
20
-
21
- expect(syncRet.syncToken).toBeGreaterThan(0);
22
- expect(syncRet.items.length).toBeGreaterThan(0);
23
- });
24
- });
25
-
@@ -1,27 +0,0 @@
1
- import { createApiClient } from './apiClients.config';
2
-
3
-
4
- /*
5
- This file contains static references to content from the instance configured in the apiClient.config file.
6
- */
7
-
8
- describe('getSyncPages:', () => {
9
- jest.setTimeout(120000); // equivalent to this.timeout('120s')
10
-
11
- it('should retrieve the oldest page items and syncToken', async () => {
12
- const api = createApiClient();
13
-
14
- let syncToken = 0;
15
-
16
- //sync from scratch
17
- const syncRet = await api.getSyncPages({
18
- syncToken: syncToken,
19
- pageSize: 100,
20
- locale: 'en-us',
21
- });
22
-
23
- expect(syncRet.syncToken).toBeGreaterThan(0);
24
- expect(syncRet.items.length).toBeGreaterThan(0);
25
- });
26
- });
27
-
@@ -1,40 +0,0 @@
1
- import { createApiClient } from './apiClients.config';
2
- /*
3
- This file contains static references to content from the instance configured in the apiClient.config file.
4
- */
5
-
6
- /* GET URL REDIRECTIONS *********************************************************/
7
-
8
-
9
- describe('getUrlRedirections:', () => {
10
- jest.setTimeout(120000); // equivalent to this.timeout('120s')
11
-
12
- let persistedLastAccessDate = null;
13
-
14
- it('should retrieve the list of URL redirections', async () => {
15
- const api = createApiClient();
16
- const { lastAccessDate, isUpToDate, items } = await api.getUrlRedirections({
17
- lastAccessDate: null,
18
- });
19
-
20
- expect(Array.isArray(items)).toBe(true);
21
- expect(isUpToDate).toBe(false);
22
- expect(lastAccessDate).toBeDefined();
23
-
24
- let dt = new Date(lastAccessDate);
25
- expect(dt.getUTCFullYear()).toBeGreaterThan(2000);
26
-
27
- persistedLastAccessDate = lastAccessDate;
28
- });
29
-
30
- it('should retrieve an empty list of URL redirections with saved last access date', async () => {
31
- const api = createApiClient();
32
- const { lastAccessDate, items, isUpToDate } = await api.getUrlRedirections({
33
- lastAccessDate: persistedLastAccessDate,
34
- });
35
-
36
- expect(Array.isArray(items)).toBe(true);
37
- expect(isUpToDate).toBe(true);
38
- expect(items.length).toBe(0);
39
- });
40
- });