Skip to content

Commit 5914be4

Browse files
teams test cases for types support
1 parent 04dcac5 commit 5914be4

File tree

4 files changed

+63
-11
lines changed

4 files changed

+63
-11
lines changed

test/typescript/teams.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ export function testTeams (organization: Organization) {
5252
})
5353
.catch(done)
5454
})
55+
test('should update team when update data is passed', done => {
56+
const updateData = {
57+
name: 'name',
58+
users: [
59+
{
60+
email: 'abc@abc.com'
61+
}
62+
],
63+
organizationRole: 'blt09e5dfced326aaea',
64+
stackRoleMapping: []
65+
}
66+
organization.teams(teamUid).update(updateData)
67+
.then((team) => {
68+
expect(team.name).to.be.equal(updateData.name)
69+
expect(team.createdByUserName).not.to.be.equal(undefined)
70+
expect(team.updatedByUserName).not.to.be.equal(undefined)
71+
done()
72+
})
73+
.catch(done)
74+
})
5575
})
5676
}
5777

types/teams/index.d.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ import { AnyProperty, SystemFields } from "../utility/fields";
22
import { ContentstackCollection } from '../contentstackCollection'
33
import { Creatable, SystemFunction } from "../utility/operations";
44
import { User, Users } from "./teamUsers";
5-
import { StackRoleMapping, StackRoleMappings } from "./stackRoleMapping";
5+
import { StackRoleMapping, StackRoleMappings, StackRoleMappingData } from "./stackRoleMapping";
66

7-
export interface Team extends SystemFields, SystemFunction<Team> {
8-
update(data?:TeamData, param?: { includeUserDetails?: boolean}): Promise<Team>
9-
user(): User
7+
export interface Team extends TeamData {
8+
update(data: TeamData, param?: { includeUserDetails?: boolean}): Promise<AnyProperty>
9+
users(): User
1010
users(uid: string): Users
1111
stackRoleMappings(): StackRoleMappings
1212
stackRoleMappings(uid: string): StackRoleMapping
13+
fetch(): Promise<Team>
14+
delete(): Promise<AnyProperty>
1315
}
1416

1517
export interface Teams extends Creatable<Team, TeamData> {
16-
}
17-
18-
export interface Teams {
1918
fetchAll(params?: AnyProperty): Promise<ContentstackCollection<Teams>>
2019
}
2120

2221
export interface TeamData extends AnyProperty {
23-
name: string,
24-
users: any,
25-
stackRoleMapping: any,
26-
organizationRole: string
22+
uid?: string,
23+
name?: string,
24+
users?: any,
25+
stackRoleMapping?: StackRoleMappingData[] | [],
26+
organizationRole?: string
2727
}
2828

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { AnyProperty, SystemFields } from "../../utility/fields";
2+
import { ContentstackCollection } from '../../contentstackCollection'
3+
import { SystemFunction } from "../../utility/operations";
4+
5+
export interface StackRoleMapping extends SystemFields, SystemFunction<StackRoleMapping> {
6+
update(data: { stackRoleMapping: StackRoleMappingData }): Promise<StackRoleMapping>
7+
}
8+
9+
export interface StackRoleMappings {
10+
fetchAll(params?: AnyProperty): Promise<ContentstackCollection<StackRoleMappings>>
11+
add(data: { stackRoleMapping: StackRoleMappingData }): Promise<StackRoleMapping>
12+
}
13+
14+
export interface StackRoleMappingData extends AnyProperty {
15+
stackApiKey?: string,
16+
roles: string[]
17+
}

types/teams/teamUsers/index.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { AnyProperty, SystemFields } from "../../utility/fields";
2+
import { Creatable, Queryable, SystemFunction } from "../../utility/operations";
3+
4+
export interface User extends SystemFields, SystemFunction<User> {
5+
}
6+
7+
export interface Users extends Creatable<User, {User: UserData}> {
8+
}
9+
10+
export interface Users extends Queryable<User, {User: UserData}> {
11+
}
12+
13+
export interface UserData extends AnyProperty {
14+
users: string[]
15+
}

0 commit comments

Comments
 (0)