Skip to content

Commit e2be396

Browse files
feat: added api test
1 parent 6512751 commit e2be396

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/api/entry-test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,45 @@ describe('Entry api Test', () => {
190190
})
191191
.catch(done)
192192
})
193+
194+
it('Create and update an entry with asset', done => {
195+
// get asset
196+
let asset;
197+
makeAsset()
198+
.query()
199+
.find()
200+
.then((collection) => {
201+
asset = collection.items[0];
202+
// create entry
203+
let entry = {
204+
...entryFirst,
205+
title: "uniqueTitle45",
206+
modular_blocks: [
207+
{
208+
block1: {
209+
file: asset.uid
210+
}
211+
}
212+
]
213+
};
214+
makeEntry(multiPageCT.content_type.uid)
215+
.create({entry: entry})
216+
.then(entry => {
217+
const newTitle = "updated title";
218+
entry.title = newTitle;
219+
entry.update().then(updatedEntry => {
220+
expect(updatedEntry.title).to.be.equal(newTitle);
221+
done();
222+
})
223+
})
224+
})
225+
});
193226
})
194227

195228
function makeEntry (contentType, uid = null) {
196229
return client.stack({ api_key: stack.api_key }).contentType(contentType).entry(uid)
197230
}
231+
232+
function makeAsset (uid = null) {
233+
return client.stack({ api_key: stack.api_key }).asset(uid)
234+
}

0 commit comments

Comments
 (0)