-
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
ee4ffed
commit dff07de
Showing
3 changed files
with
72 additions
and
1 deletion.
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,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) | ||
}) | ||
}) | ||
}) | ||
}) | ||
} |
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