Skip to content

Commit bb72449

Browse files
committed
Organization unit test
1 parent 05fff29 commit bb72449

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

lib/organization/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function Organization (http, data) {
107107
*/
108108
this.addUser = async (data) => {
109109
try {
110-
const response = await http.post(`${this.urlPath}/share`, { share: { data } })
110+
const response = await http.post(`${this.urlPath}/share`, { share: { ...data } })
111111
if (response.data) {
112112
return new ContentstackCollection(response, http, null, UserCollection)
113113
} else {
@@ -238,7 +238,7 @@ export function Organization (http, data) {
238238
}
239239

240240
export function OrganizationCollection (http, data) {
241-
const obj = cloneDeep(data.organizations)
241+
const obj = cloneDeep(data.organizations || [])
242242
const organizationCollection = obj.map((userdata) => {
243243
return new Organization(http, { organization: userdata })
244244
})

lib/stack/contentType/index.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,33 @@ export function ContentType (http, data = {}) {
9090
return new Entry(http, data)
9191
}
9292
} else {
93-
/**
93+
/**
94+
* @description The Create a content type call creates a new content type in a particular stack of your Contentstack account.
95+
* @memberof ContentType
96+
* @func generateUid
97+
* @param {*} name Name for content type you want to create.
98+
* @example
99+
* import * as contentstack from '@contentstack/management'
100+
* const client = contentstack.client()
101+
* const contentType = client.stack().contentType()
102+
* const contentTypeName = 'My New contentType'
103+
* const content_type = {
104+
* name: name,
105+
* uid: contentType.generateUid(name)
106+
* }
107+
* contentType
108+
* .create({ content_type })
109+
* .then((contenttype) => console.log(contenttype))
110+
*
111+
*/
112+
this.generateUid = (name) => {
113+
if (!name) {
114+
throw new TypeError('Expected parameter name')
115+
}
116+
return name.replace(/[^A-Z0-9]+/gi, '_').toLowerCase()
117+
}
118+
119+
/**
94120
* @description The Create a content type call creates a new content type in a particular stack of your Contentstack account.
95121
* @memberof ContentType
96122
* @func create

0 commit comments

Comments
 (0)