11import { TaxonomyQuery } from '../../src/lib/taxonomy-query' ;
2+ import { Taxonomy } from '../../src/lib/taxonomy' ;
23import { AxiosInstance , httpClient } from '@contentstack/core' ;
34import MockAdapter from 'axios-mock-adapter' ;
45import { taxonomyFindResponseDataMock } from '../utils/mocks' ;
56import { MOCK_CLIENT_OPTIONS } from '../utils/constant' ;
67
78describe ( 'ta class' , ( ) => {
8- let taxonomy : TaxonomyQuery ;
9+ let taxonomies : TaxonomyQuery ;
10+ let taxonomy : Taxonomy ;
911 let client : AxiosInstance ;
1012 let mockClient : MockAdapter ;
1113
@@ -15,12 +17,19 @@ describe('ta class', () => {
1517 } ) ;
1618
1719 beforeEach ( ( ) => {
18- taxonomy = new TaxonomyQuery ( client ) ;
20+ taxonomies = new TaxonomyQuery ( client ) ;
21+ taxonomy = new Taxonomy ( client , 'taxonomy_testing' ) ;
1922 } ) ;
2023
21- it ( 'should return response data when successful' , async ( ) => {
24+ it ( 'should return all taxonomies in the response data when successful' , async ( ) => {
2225 mockClient . onGet ( '/taxonomy-manager' ) . reply ( 200 , taxonomyFindResponseDataMock ) ; //TODO: change to /taxonomies
23- const response = await taxonomy . find ( ) ;
26+ const response = await taxonomies . find ( ) ;
2427 expect ( response ) . toEqual ( taxonomyFindResponseDataMock ) ;
2528 } ) ;
29+
30+ it ( 'should return single taxonomy in the response data when successful' , async ( ) => {
31+ mockClient . onGet ( '/taxonomy-manager/taxonomy_testing' ) . reply ( 200 , taxonomyFindResponseDataMock . taxonomies [ 0 ] ) ; //TODO: change to /taxonomies/taxonomyUid
32+ const response = await taxonomy . fetch ( ) ;
33+ expect ( response ) . toEqual ( taxonomyFindResponseDataMock . taxonomies [ 0 ] ) ; //TODO: change to taxonomyFindResponseDataMock
34+ } ) ;
2635} ) ;
0 commit comments