mirror of
https://github.com/dzeiocom/libs.git
synced 2025-06-14 03:39:18 +00:00
Added easy-sitemap lib
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
@ -0,0 +1,11 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Basic Sitemap Tests should not add changefreq if value is incorrect 1`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><urlset xmlns=\\"http://www.sitemaps.org/schemas/sitemap/0.9\\"><url><loc>https://www.example.com/path</loc></url></urlset>"`;
|
||||
|
||||
exports[`Basic Sitemap Tests should not add priority when it is incorrect 1`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><urlset xmlns=\\"http://www.sitemaps.org/schemas/sitemap/0.9\\"><url><loc>https://www.example.com/path</loc></url></urlset>"`;
|
||||
|
||||
exports[`Basic Sitemap Tests should return a basic sitemap 1`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><urlset xmlns=\\"http://www.sitemaps.org/schemas/sitemap/0.9\\"><url><loc>https://www.example.com/path</loc></url><url><loc>https://www.example.com/</loc></url></urlset>"`;
|
||||
|
||||
exports[`Basic Sitemap Tests should return a sitemap 1`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><urlset xmlns=\\"http://www.sitemaps.org/schemas/sitemap/0.9\\"><url><loc>https://www.example.com/path</loc><changefreq>always</changefreq><lastmod>2021-01-20T00:00:00.000Z</lastmod><priority>1</priority></url><url><loc>https://www.example.com/</loc></url></urlset>"`;
|
||||
|
||||
exports[`Basic Sitemap Tests should return an empty sitemap 1`] = `"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><urlset xmlns=\\"http://www.sitemaps.org/schemas/sitemap/0.9\\"></urlset>"`;
|
43
packages/easy-sitemap/__tests__/index.test.ts
Normal file
43
packages/easy-sitemap/__tests__/index.test.ts
Normal file
@ -0,0 +1,43 @@
|
||||
/// <reference types="jest" />
|
||||
|
||||
import Sitemap from '../src/Sitemap'
|
||||
|
||||
describe('Basic Sitemap Tests', () => {
|
||||
it('should return an empty sitemap', () => {
|
||||
const sitemap = new Sitemap('https://www.example.com')
|
||||
expect(sitemap.build()).toMatchSnapshot()
|
||||
})
|
||||
it('should return a basic sitemap', () => {
|
||||
const sitemap = new Sitemap('https://www.example.com')
|
||||
sitemap.addEntry('/path')
|
||||
sitemap.addEntry('/')
|
||||
expect(sitemap.build()).toMatchSnapshot()
|
||||
})
|
||||
it('should return a sitemap', () => {
|
||||
const sitemap = new Sitemap('https://www.example.com')
|
||||
sitemap.addEntry('/path', {
|
||||
changefreq: 'always',
|
||||
lastmod: new Date('2021-01-20'),
|
||||
priority: 1
|
||||
})
|
||||
sitemap.addEntry('/')
|
||||
expect(sitemap.build()).toMatchSnapshot()
|
||||
})
|
||||
it('should not add priority when it is incorrect', () => {
|
||||
const sitemap = new Sitemap('https://www.example.com')
|
||||
sitemap.addEntry('/path', {
|
||||
// @ts-expect-error
|
||||
priority: 255
|
||||
})
|
||||
expect(sitemap.build()).toMatchSnapshot()
|
||||
})
|
||||
it('should not add changefreq if value is incorrect', () => {
|
||||
const sitemap = new Sitemap('https://www.example.com')
|
||||
sitemap.addEntry('/path', {
|
||||
// @ts-expect-error
|
||||
changefreq: 'pouet'
|
||||
})
|
||||
expect(sitemap.build()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
})
|
Reference in New Issue
Block a user