Skip to content

Commit 1cd0266

Browse files
committed
backup
1 parent 97ae499 commit 1cd0266

File tree

3 files changed

+48
-10
lines changed

3 files changed

+48
-10
lines changed

test/core.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,52 @@ const Stack = Contentstack.Stack(config)
1717
let db
1818

1919
describe('# Core', () => {
20+
2021
beforeAll(() => {
2122
return Stack.connect().then((dbInstance) => {
2223
db = dbInstance
2324
})
2425
})
26+
2527
beforeAll(() => {
26-
return db.collection(collectionName).insertMany(authors)
28+
return db.collection(collectionName)
29+
.insertMany(authors)
2730
.then(() => {
28-
return db.collection(collectionName).insertMany(blogs)
31+
return db.collection(collectionName)
32+
.insertMany(blogs)
2933
})
3034
.then(() => {
31-
return db.collection(collectionName).insertMany(products)
35+
return db.collection(collectionName)
36+
.insertMany(products)
3237
})
3338
.then(() => {
34-
return db.collection(collectionName).insertMany(categories)
39+
return db.collection(collectionName)
40+
.insertMany(categories)
3541
})
3642
.then(() => {
37-
return db.collection(collectionName).insertMany(assets)
43+
return db.collection(collectionName)
44+
.insertMany(assets)
3845
})
3946
.then(() => {
40-
return db.collection(collectionName).insertMany(content_types)
47+
return db.collection(collectionName)
48+
.insertMany(content_types)
4149
})
4250
.catch((error) => {
4351
expect(error).toBeNull()
4452
})
4553
})
54+
4655
afterAll(() => {
47-
return db.collection(collectionName).drop().then(() => {
48-
return Stack.close()
49-
})
56+
return db.collection(collectionName)
57+
.drop()
58+
.then(() => {
59+
return Stack.close()
60+
})
5061
})
5162

5263
test('initialize stack', () => {
53-
expect(Contentstack.Stack()).toHaveProperty('connect')
64+
expect(Contentstack.Stack())
65+
.toHaveProperty('connect')
5466
})
5567

5668
describe('entries', () => {

test/data/content_types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export const content_types = [
3232
},
3333
title: 'Blog',
3434
uid: 'blog',
35+
reference: {
36+
authors: 'author',
37+
self_reference: 'blog'
38+
}
3539
},
3640
{
3741
content_type_uid: '_content_types',
@@ -66,6 +70,10 @@ export const content_types = [
6670
},
6771
title: 'Author',
6872
uid: 'author',
73+
reference: {
74+
blogs: 'blog',
75+
self_reference: 'author'
76+
}
6977
},
7078
{
7179
content_type_uid: '_content_types',

test/references.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,24 @@ describe('# References', () => {
140140
expect(error).toBeNull()
141141
})
142142
})
143+
144+
test('.include()', () => {
145+
return Stack.contentType('blog')
146+
.entries()
147+
.include(['authors'])
148+
.find()
149+
.then((result) => {
150+
(result as any).entries.forEach((entry) => {
151+
itemPropertyChecks(result)
152+
expect(result).toHaveProperty('entries')
153+
expect((result as any).content_type_uid).toEqual('blog')
154+
expect((result as any).entries).toHaveLength(5)
155+
expect(entry).not.toHaveProperty('self_reference')
156+
})
157+
}).catch((error) => {
158+
expect(error).toBeNull()
159+
})
160+
})
143161
})
144162
})
145163

0 commit comments

Comments
 (0)