|
| 1 | +import seoService from './seo'; |
| 2 | + |
| 3 | +describe('SEO Service', () => { |
| 4 | + function buildViewData(){ |
| 5 | + return { |
| 6 | + title: 'Title', |
| 7 | + description: 'Description', |
| 8 | + keywords: 'Keywords', |
| 9 | + imageFilename: 'test.png' |
| 10 | + }; |
| 11 | + } |
| 12 | + |
| 13 | + it('should build seo items', () => { |
| 14 | + expect(seoService.buildHead(buildViewData())).toEqual({ |
| 15 | + title: { |
| 16 | + inner: 'Title' |
| 17 | + }, |
| 18 | + meta: [ |
| 19 | + { name: 'application-name', content: '' }, |
| 20 | + { name: 'description', content: 'Description', id: 'desc' }, |
| 21 | + { name: 'keywords', content: 'Keywords' }, |
| 22 | + { name: 'twitter:card', content: 'summary' }, |
| 23 | + { name: 'twitter:title', content: 'Title' }, |
| 24 | + { name: 'twitter:description', content: 'Description' }, |
| 25 | + { name: 'twitter:site', content: '@ceppromise' }, |
| 26 | + { name: 'twitter:creator', content: '@ceppromise' }, |
| 27 | + { itemprop: 'name', content: 'Title' }, |
| 28 | + { itemprop: 'desc', content: 'Description' }, |
| 29 | + { property: 'og:title', content: 'Title' }, |
| 30 | + { property: 'og:image', content: 'http://localhost:7000/images/test.png' } |
| 31 | + ] |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + it('should build seo items with default image if no image filename has been provided', () => { |
| 36 | + const viewData = buildViewData(); |
| 37 | + delete viewData.imageFilename; |
| 38 | + expect(seoService.buildHead(viewData)).toEqual({ |
| 39 | + title: { |
| 40 | + inner: 'Title' |
| 41 | + }, |
| 42 | + meta: [ |
| 43 | + { name: 'application-name', content: '' }, |
| 44 | + { name: 'description', content: 'Description', id: 'desc' }, |
| 45 | + { name: 'keywords', content: 'Keywords' }, |
| 46 | + { name: 'twitter:card', content: 'summary' }, |
| 47 | + { name: 'twitter:title', content: 'Title' }, |
| 48 | + { name: 'twitter:description', content: 'Description' }, |
| 49 | + { name: 'twitter:site', content: '@ceppromise' }, |
| 50 | + { name: 'twitter:creator', content: '@ceppromise' }, |
| 51 | + { itemprop: 'name', content: 'Title' }, |
| 52 | + { itemprop: 'desc', content: 'Description' }, |
| 53 | + { property: 'og:title', content: 'Title' }, |
| 54 | + { property: 'og:image', content: 'http://localhost:7000/images/cep-promise-288x288.png' } |
| 55 | + ] |
| 56 | + }); |
| 57 | + }); |
| 58 | +}); |
0 commit comments