Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 15 additions & 31 deletions test/sanity-check/api/branch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,30 @@ describe('Branch api Test', () => {
client = contentstackClient(user.authtoken)
})

it('should return master branch when query is called', done => {
it('should create Branch from staging', done => {
makeBranch()
.query()
.find()
.create({ branch: devBranch })
.then((response) => {
expect(response.items.length).to.be.equal(1)
var item = response.items[0]
expect(item.urlPath).to.be.equal(`/stacks/branches/${item.uid}`)
expect(item.delete).to.not.equal(undefined)
expect(item.fetch).to.not.equal(undefined)
expect(response.uid).to.be.equal(devBranch.uid)
expect(response.urlPath).to.be.equal(`/stacks/branches/${devBranch.uid}`)
expect(response.source).to.be.equal(devBranch.source)
expect(response.alias).to.not.equal(undefined)
expect(response.delete).to.not.equal(undefined)
expect(response.fetch).to.not.equal(undefined)
done()
})
.catch(done)
})

it('should create staging branch', done => {
it('should return master branch when query is called', done => {
makeBranch()
.create({ branch: stageBranch })
.query()
.find()
.then((response) => {
expect(response.uid).to.be.equal(stageBranch.uid)
expect(response.urlPath).to.be.equal(`/stacks/branches/${stageBranch.uid}`)
expect(response.source).to.be.equal(stageBranch.source)
expect(response.alias).to.not.equal(undefined)
expect(response.delete).to.not.equal(undefined)
expect(response.fetch).to.not.equal(undefined)
var item = response.items[0]
expect(item.urlPath).to.be.equal(`/stacks/branches/${item.uid}`)
expect(item.delete).to.not.equal(undefined)
expect(item.fetch).to.not.equal(undefined)
done()
})
.catch(done)
Expand Down Expand Up @@ -72,21 +71,6 @@ describe('Branch api Test', () => {
.catch(done)
})

it('should create Branch from staging', done => {
makeBranch()
.create({ branch: devBranch })
.then((response) => {
expect(response.uid).to.be.equal(devBranch.uid)
expect(response.urlPath).to.be.equal(`/stacks/branches/${devBranch.uid}`)
expect(response.source).to.be.equal(devBranch.source)
expect(response.alias).to.not.equal(undefined)
expect(response.delete).to.not.equal(undefined)
expect(response.fetch).to.not.equal(undefined)
done()
})
.catch(done)
})

it('should query branch for specific condition', done => {
makeBranch()
.query({ query: { source: 'main' } })
Expand Down
28 changes: 28 additions & 0 deletions test/sanity-check/api/stack-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { expect } from 'chai'
import { describe, it, setup } from 'mocha'
import { jsonReader, jsonWrite } from '../utility/fileOperations/readwrite'
import { contentstackClient } from '../utility/ContentstackClient.js'
import { stageBranch } from '../mock/branch.js'

import dotenv from 'dotenv'
dotenv.config()

Expand Down Expand Up @@ -156,3 +158,29 @@ describe('Stack api Test', () => {
.catch(done)
})
})

describe('Branch creation api Test', () => {
setup(() => {
const user = jsonReader('loggedinuser.json')
client = contentstackClient(user.authtoken)
})

it('should create staging branch', done => {
makeBranch()
.create({ branch: stageBranch })
.then((response) => {
expect(response.uid).to.be.equal(stageBranch.uid)
expect(response.urlPath).to.be.equal(`/stacks/branches/${stageBranch.uid}`)
expect(response.source).to.be.equal(stageBranch.source)
expect(response.alias).to.not.equal(undefined)
expect(response.delete).to.not.equal(undefined)
expect(response.fetch).to.not.equal(undefined)
done()
})
.catch(done)
})
})

function makeBranch (uid = null) {
return client.stack({ api_key: process.env.API_KEY }).branch(uid)
}
4 changes: 2 additions & 2 deletions test/sanity-check/sanity.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require('./api/user-test')
require('./api/organization-test')
require('./api/stack-test')
require('./api/branch-test')
require('./api/branchAlias-test')
require('./api/contentType-test')
require('./api/asset-test')
require('./api/entry-test')
require('./api/branch-test')
require('./api/branchAlias-test')
require('./api/contentType-delete-test')
require('./api/taxonomy-test')
require('./api/terms-test')