import { contextVariables, templateContext } from '../template-context'; describe('templateContext', () => { const types = ['post', 'page', 'product', 'recomaze_location']; const taxonomies = ['category', 'product_cat', 'product_brand']; it('names the page a template is for', () => { expect(templateContext('pt_post_title', types, taxonomies)).toBe( 'post:post' ); expect( templateContext('pt_recomaze_location_description', types, taxonomies) ).toBe('post:recomaze_location'); expect(templateContext('pt_product_archive_title', types, taxonomies)).toBe( 'archive:product' ); expect(templateContext('tax_product_cat_title', types, taxonomies)).toBe( 'term:product_cat' ); expect(templateContext('home_og_title', types, taxonomies)).toBe('home'); expect(templateContext('date_archive_title', types, taxonomies)).toBe( 'date' ); expect(templateContext('not_found_title', types, taxonomies)).toBe( 'not_found' ); expect(templateContext('separator', types, taxonomies)).toBe(''); }); }); describe('contextVariables', () => { const variables = [ { name: '%title%', label: 'Title', example: 'Hoodie with Logo' }, { name: '%wc_price%', label: 'Price', example: '45.00 USD' }, ]; it('keeps the variables of the set with what they print there', () => { expect( contextVariables(variables, { '%title%': 'How to wash a hoodie' }) ).toEqual([ { name: '%title%', label: 'Title', example: 'How to wash a hoodie' }, ]); expect(contextVariables(variables, undefined)).toBe(variables); }); });