1
1
mirror of https://github.com/primer/css.git synced 2024-11-25 18:26:14 +03:00
css/__tests__/docs.test.js

34 lines
810 B
JavaScript
Raw Normal View History

import {getNavigationLinks, getContentFrontmatter} from './utils/docs'
2021-03-30 20:01:19 +03:00
2021-03-31 02:53:47 +03:00
let navLinks, contentFM
2021-03-30 20:01:19 +03:00
2021-03-31 02:53:47 +03:00
beforeAll(async () => {
contentFM = await getContentFrontmatter()
navLinks = getNavigationLinks()
2021-03-30 20:01:19 +03:00
})
describe('frontmatter', () => {
2021-03-31 02:53:47 +03:00
it('page title matches link title', () => {
2021-04-01 20:56:12 +03:00
for (const link of navLinks) {
2021-03-31 02:53:47 +03:00
const content = contentFM[link['url']]
expect(content).not.toBeNull()
expect(content['title']).toBe(link['title'])
2021-04-01 20:56:12 +03:00
}
2021-03-31 02:53:47 +03:00
})
2021-03-30 20:01:19 +03:00
2021-03-31 02:53:47 +03:00
it('contains path attribute', () => {
2021-04-01 20:56:12 +03:00
for (const v of Object.values(contentFM)) {
2021-03-31 02:53:47 +03:00
expect(v['path']).not.toBeNull()
2021-04-01 20:56:12 +03:00
}
2021-03-31 02:53:47 +03:00
})
2021-03-30 20:01:19 +03:00
})
describe('navigation', () => {
it('has a file for each nav item', () => {
2021-04-01 20:56:12 +03:00
for (const link of navLinks) {
2021-03-31 02:53:47 +03:00
const content = contentFM[link['url']]
expect(content).not.toBeNull()
2021-04-01 20:56:12 +03:00
}
2021-03-30 20:01:19 +03:00
})
})