Skip to content

Commit

Permalink
test: ✅ taxonomy API test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithad0703 committed Oct 11, 2023
1 parent ee4ffed commit dff07de
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/typescript/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { createApp, deleteApp, fetchApp, installation, updateApp, updateAuth } f
import { deployment, hosting } from './hosting';
import { orgAppRequest } from './app-request';
import { authorization } from './authorization';
import { testTaxonomy } from './taxonomy';
dotenv.config()
jest.setTimeout(10000);

Expand Down Expand Up @@ -100,6 +101,8 @@ describe('Typescript API test', () => {
deleteAsset(stack)
queryOnAsset(stack)

testTaxonomy(stack)

deleteEnvironment(stack)

logout(client)
Expand Down
68 changes: 68 additions & 0 deletions test/typescript/taxonomy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { expect } from "chai";
import { Stack } from "../../types/stack";

var taxonomyUID = ''
export function testTaxonomy(stack: Stack) {
describe('Taxonomy API test', () => {
test('Create taxonomy', done => {
const taxonomy = {
uid: 'uid',
name: 'taxonomy',
description: 'Description for Taxonomy'
}
stack.taxonomy().create({taxonomy})
.then((taxonomyResponse) => {
console.log(taxonomyResponse)
expect(taxonomyResponse.uid).to.be.equal(taxonomy.uid)
expect(taxonomyResponse.name).to.be.equal(taxonomy.name)
done()
})
.catch(done)
})
test('Fetch taxonomy from uid', done => {
stack.taxonomy(taxonomyUID).fetch()
.then((taxonomyResponse) => {
console.log(taxonomyResponse)
expect(taxonomyResponse.uid).to.be.equal(taxonomyUID)
expect(taxonomyResponse.name).not.to.be.equal('a')
done()
})
.catch(done)
})
test('Update taxonomy from uid', done => {
stack.taxonomy(taxonomyUID)
.fetch()
.then((taxonomyResponse) => {
taxonomyResponse.name = 'updated name'
return taxonomyResponse.update()
})
.then((taxonomyResponse) => {
console.log(taxonomyResponse)
expect(taxonomyResponse.uid).to.be.equal(taxonomyUID)
expect(taxonomyResponse.name).to.be.equal('updated name')
done()
})
.catch(done)
})
test('Delete taxonomy from uid', done => {
stack.taxonomy(taxonomyUID)
.delete()
.then((taxonomyResponse) => {
expect(taxonomyResponse.notice).to.be.equal('Taxonomy deleted successfully.')
done()
})
.catch(done)
})
test('Query to get all taxonomies', async () => {
await stack.taxonomy()
.query()
.find()
.then((response) => {
response.items.forEach((taxonomyResponse) => {
expect(taxonomyResponse.uid).to.be.not.equal(null)
expect(taxonomyResponse.name).to.be.not.equal(null)
})
})
})
})
}
2 changes: 1 addition & 1 deletion types/stack/taxonomy/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export interface Taxonomies extends Creatable<Taxonomy, {taxonomy: TaxonomyData}

export interface TaxonomyData extends AnyProperty {
name: string
taxonomy_uid: string
uid: string
description: string
}

0 comments on commit dff07de

Please sign in to comment.