Skip to content

Commit 87fead8

Browse files
test: ✅ changes made in taxonomy function in stack class
1 parent 272be8d commit 87fead8

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

lib/stack/index.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,28 @@ export function Stack (http, data) {
685685
}
686686
return new Role(http, data)
687687
}
688+
689+
/**
690+
* @description Taxonomies allow you to group a collection of content within a stack. Using taxonomies you can group content types that need to work together
691+
* @param {String} uid The UID of the Taxonomy you want to get details.
692+
* @returns {Taxonomy} Instance of Taxonomy.
693+
* @example
694+
* import * as contentstack from '@contentstack/management'
695+
* const client = contentstack.client()
696+
*
697+
* client.stack({ api_key: 'api_key'}).taxonomy().create()
698+
* .then((taxonomy) => console.log(taxonomy))
699+
*
700+
* client.stack({ api_key: 'api_key'}).taxonomy('taxonomy_uid').fetch()
701+
* .then((taxonomy) => console.log(taxonomy))
702+
*/
703+
this.taxonomy = (taxonomyUid = '') => {
704+
const data = { stackHeaders: this.stackHeaders }
705+
if (taxonomyUid) {
706+
data.taxonomy = { uid: taxonomyUid }
707+
}
708+
return new Taxonomy(http, data)
709+
}
688710
} else {
689711
/**
690712
* @description The Create stack call creates a new stack in your Contentstack account.
@@ -744,28 +766,6 @@ export function Stack (http, data) {
744766
}
745767
return new AuditLog(http, data)
746768
}
747-
748-
/**
749-
* @description Taxonomies allow you to group a collection of content within a stack. Using taxonomies you can group content types that need to work together
750-
* @param {String} uid The UID of the Taxonomy you want to get details.
751-
* @returns {Taxonomy} Instance of Taxonomy.
752-
* @example
753-
* import * as contentstack from '@contentstack/management'
754-
* const client = contentstack.client()
755-
*
756-
* client.stack({ api_key: 'api_key'}).taxonomy().create()
757-
* .then((taxonomy) => console.log(taxonomy))
758-
*
759-
* client.stack({ api_key: 'api_key'}).taxonomy('taxonomy_uid').fetch()
760-
* .then((taxonomy) => console.log(taxonomy))
761-
*/
762-
this.taxonomy = (taxonomyUid = '') => {
763-
const data = { stackHeaders: this.stackHeaders }
764-
if (taxonomyUid) {
765-
data.taxonomy = { uid: taxonomyUid }
766-
}
767-
return new Taxonomy(http, data)
768-
}
769769
}
770770
return this
771771
}

test/api/taxonomy-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ describe('taxonomy api Test', () => {
3636
makeTaxonomy(taxonomyUID)
3737
.fetch()
3838
.then((taxonomyResponse) => {
39-
expect(taxonomyResponse.name).to.be.equal(taxonomy.name)
39+
expect(taxonomyResponse.uid).to.be.equal(taxonomyUID)
40+
expect(taxonomyResponse.name).to.be.not.equal(null)
4041
done()
4142
})
4243
.catch(done)

0 commit comments

Comments
 (0)