-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e79409f
commit 83c136c
Showing
4 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { expect } from "chai"; | ||
import { Organization } from "../../types/organization"; | ||
|
||
let teamUid = '' | ||
export function testTeams (organization: Organization) { | ||
describe('Contentstack Teams test', () => { | ||
test('should fetch all the teams', done => { | ||
organization.teams().fetchAll() | ||
.then((teams) => { | ||
expect(teams[0].organizationUid).not.to.be.equal(undefined) | ||
expect(teams[0].name).not.to.be.equal(null) | ||
expect(teams[0].created_by).not.to.be.equal(null) | ||
expect(teams[0].updated_by).not.to.be.equal(null) | ||
done() | ||
}) | ||
.catch(done) | ||
}) | ||
test('should fetch the team when correct organization uid and team uid is passed', done => { | ||
organization.teams(teamUid).fetch() | ||
.then((teams) => { | ||
expect(teams.uid).to.be.equal(teamUid) | ||
expect(teams.organizationUid).not.to.be.equal(undefined) | ||
expect(teams.name).not.to.be.equal(null) | ||
expect(teams.created_by).not.to.be.equal(null) | ||
expect(teams.updated_by).not.to.be.equal(null) | ||
done() | ||
}) | ||
.catch(done) | ||
}) | ||
test('should create new team when required object is passed', done => { | ||
const createData = { | ||
name: 'test_team', | ||
users: [], | ||
stackRoleMapping: [], | ||
organizationRole: '' | ||
} | ||
organization.teams().create(createData) | ||
.then((teams) => { | ||
expect(teams.uid).not.to.be.equal(null) | ||
expect(teams.name).not.to.be.equal(null) | ||
expect(teams.stackRoleMapping).not.to.be.equal(null) | ||
expect(teams.organizationRole).not.to.be.equal(null) | ||
done() | ||
}) | ||
.catch(done) | ||
}) | ||
test('should delete team when correct organization uid and team uid is passed', done => { | ||
organization.teams(teamUid).delete() | ||
.then((teams) => { | ||
expect(teams.status).to.be.equal(204) | ||
done() | ||
}) | ||
.catch(done) | ||
}) | ||
}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { AnyProperty, SystemFields } from "../utility/fields"; | ||
import { ContentstackCollection } from '../contentstackCollection' | ||
import { Creatable, SystemFunction } from "../utility/operations"; | ||
import { User, Users } from "./teamUsers"; | ||
import { StackRoleMapping, StackRoleMappings } from "./stackRoleMapping"; | ||
|
||
export interface Team extends SystemFields, SystemFunction<Team> { | ||
update(data?:TeamData, param?: { includeUserDetails?: boolean}): Promise<Team> | ||
user(): User | ||
users(uid: string): Users | ||
stackRoleMappings(): StackRoleMappings | ||
stackRoleMappings(uid: string): StackRoleMapping | ||
} | ||
|
||
export interface Teams extends Creatable<Team, TeamData> { | ||
} | ||
|
||
export interface Teams { | ||
fetchAll(params?: AnyProperty): Promise<ContentstackCollection<Teams>> | ||
} | ||
|
||
export interface TeamData extends AnyProperty { | ||
name: string, | ||
users: any, | ||
stackRoleMapping: any, | ||
organizationRole: string | ||
} | ||
|