11import { Term } from "../../src/lib/term" ;
22import { stackInstance } from "../utils/stack-instance" ;
3- import { TTerm } from "./types" ;
3+ import { TTerm , TTerms } from "./types" ;
44
55const stack = stackInstance ( ) ;
66
77describe ( "Terms API test cases" , ( ) => {
88 it ( "should get a term by uid" , async ( ) => {
9- const result = await makeTerms ( "term1 " ) . fetch < TTerm > ( ) ;
9+ const result = await makeTerms ( "vehicles " ) . fetch < TTerm > ( ) ;
1010 expect ( result ) . toBeDefined ( ) ;
1111 expect ( result . taxonomy_uid ) . toBeDefined ( ) ;
1212 expect ( result . uid ) . toBeDefined ( ) ;
@@ -15,14 +15,21 @@ describe("Terms API test cases", () => {
1515 } ) ;
1616
1717 it ( "should get locales for a term" , async ( ) => {
18- // const result = await makeTerms("term1 ").locales().fetch();
18+ // const result = await makeTerms("vehicles ").locales().fetch();
1919 // API under building phase, so it should throw error
20- expect ( async ( ) => await makeTerms ( "term1 " ) . locales ( ) ) . rejects . toThrow ( ) ;
20+ expect ( async ( ) => await makeTerms ( "vehicles " ) . locales ( ) ) . rejects . toThrow ( ) ;
2121 // TODO: add assertions
2222 } ) ;
23+
24+ it ( "should get ancestors for a term" , async ( ) => {
25+ const result = await makeTerms ( "sleeper" ) . ancestors < TTerms > ( ) ;
26+ expect ( result ) . toBeDefined ( ) ;
27+ expect ( result . terms ) . toBeDefined ( ) ;
28+ expect ( result . terms [ 0 ] . name ) . toBeDefined ( ) ;
29+ } ) ;
2330} ) ;
2431
2532function makeTerms ( termUid = "" ) : Term {
26- const terms = stack . taxonomy ( "taxonomy_testing " ) . term ( termUid ) ;
33+ const terms = stack . taxonomy ( "taxonomy_testing_3 " ) . term ( termUid ) ;
2734 return terms ;
2835}
0 commit comments