/* eslint-env jest */ import { templateWarnings } from '../template-warnings'; const variables = [ { name: '%title%' }, { name: '%sep%' }, { name: '%sitename%' }, { name: '%term%' }, { name: '%excerpt%' }, { name: '%customfield(field-name)%' }, ]; describe('a title or description template', () => { it('passes when it reads the page', () => { expect( templateWarnings('pt_post_title', '%title% %sep% %sitename%', variables) ).toEqual([]); expect( templateWarnings( 'tax_category_title', '%term% %sep% %sitename%', variables ) ).toEqual([]); expect( templateWarnings( 'pt_product_description', '%customfield(tagline)%', variables ) ).toEqual([]); expect(templateWarnings('pt_post_title', '', variables)).toEqual([]); }); it('says a variable the site does not know prints nothing', () => { expect( templateWarnings('pt_post_title', '%title% %sep% %site_name%', variables) ).toEqual([ '%site_name% is not a variable this site knows, so it prints nothing.', ]); }); it('says when every page of the kind would get the same text', () => { expect( templateWarnings( 'tax_product_cat_title', 'Shop %sep% %sitename%', variables ) ).toEqual([ 'Every term gets this same title: add %term% or %title% so each one reads as its own page.', ]); expect( templateWarnings( 'pt_post_description', 'Guides from %sitename%', variables ) ).toEqual([ 'Every page gets this same description: add %excerpt%, %title% or another variable of the page.', ]); expect( templateWarnings( 'pt_post_archive_title', 'All posts %sep% %sitename%', variables ) ).toEqual([]); }); });