Skip to content

Commit

Permalink
added assertions to check the response
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithad0703 committed Nov 7, 2023
1 parent cd9dea7 commit 864db84
Showing 1 changed file with 40 additions and 45 deletions.
85 changes: 40 additions & 45 deletions test/api/team-stack-role-mapping-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,55 @@ describe('Teams API Test', () => {
const user = jsonReader('loggedinuser.json')
client = contentstackClient(user.authtoken)
})
it('should fetch all stackRoleMappings', async () => {
try {
makestackRoleMappings(organizationUid, teamUid).fetchAll().then((response) => {
console.log('🚀 ~ file: team-stack-role-mapping-test.js:19 ~ makestackRoleMappings ~ response:', response.stackRoleMappings[0].roles)
it('should fetch all stackRoleMappings', done => {
makestackRoleMappings(organizationUid, teamUid).fetchAll().then((response) => {
response.items.forEach((stackRoleMapping) => {
console.log(stackRoleMapping)
})
} catch (err) {
console.log("🚀 ~ file: team-stack-role-mapping-test.js:21 ~ it.only ~ err:", err)
}
expect(response).to.be.not.equal(null)
done()
})
.catch(done)
})
it('should add roles', async () => {
try {
const stackRoleMappings = {
stackApiKey: 'stackApiKey',
roles: [
'role_uid'
]
}
await makestackRoleMappings(organizationUid, teamUid).add(stackRoleMappings).then((response) => {
console.log('🚀 ~ file: team-stack-role-mapping-test.js:36 ~ awaitmakestackRoleMappings ~ response:', response)
})
} catch (err) {
console.log(err)
it('should add roles', done => {
const stackRoleMappings = {
stackApiKey: 'stackApiKey',
roles: [
'role_uid'
]
}
makestackRoleMappings(organizationUid, teamUid).add(stackRoleMappings).then((response) => {
expect(response.stackRoleMapping).not.to.be.equal(undefined)
expect(response.stackRoleMapping.roles[0]).to.be.equal(stackRoleMappings.roles[0])
expect(response.stackRoleMapping.stackApiKey).to.be.equal(stackRoleMappings.stackApiKey)
done()
})
.catch(done)
})
it('should update roles', async () => {
try {
const stackRoleMappings = {
roles: [
'role_uid1',
'role_uid2'
]
}
await makestackRoleMappings(organizationUid, teamUid, stackApiKey).update(stackRoleMappings).then((response) => {
console.log('🚀 ~ file: team-stack-role-mapping-test.js:31 ~ makestackRoleMappings ~ response:', response)
})
} catch (err) {
console.log(err.errors)
it('should update roles', done => {
const stackRoleMappings = {
roles: [
'role_uid1',
'role_uid2'
]
}
makestackRoleMappings(organizationUid, teamUid, stackApiKey).update(stackRoleMappings).then((response) => {
expect(response.stackRoleMapping).not.to.be.equal(undefined)
expect(response.stackRoleMapping.roles[0]).to.be.equal(stackRoleMappings.roles[0])
expect(response.stackRoleMapping.stackApiKey).to.be.equal(stackApiKey)
done()
})
.catch(done)
})
it('should delete roles', async () => {
try {
await makestackRoleMappings(organizationUid, teamUid, stackApiKey).delete().then((response) => {
console.log('🚀 ~ file: team-stack-role-mapping-test.js:31 ~ makestackRoleMappings ~ response:', response)
})
} catch (err) {
console.log(err.errors)
}
it('should delete roles', done => {
makestackRoleMappings(organizationUid, teamUid, stackApiKey).delete().then((response) => {
expect(response.status).to.be.equal(204)
done()
})
.catch(done)
})
})

function makestackRoleMappings (organizationUid, teamUid, stackApiKey = null) {
return client.organization(organizationUid).teams(teamUid).stackRoleMappings(stackApiKey)
}

// delete done
// update done
// add done

0 comments on commit 864db84

Please sign in to comment.