Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
48 lines
2.3 KiB
JavaScript
48 lines
2.3 KiB
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
const { difference, isPlainObject } = require('lodash')
|
|
const { getJSON } = require('../helpers')
|
|
const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
|
|
// list of REST markdown files that do not correspond to REST API resources
|
|
// TODO could we get this list dynamically, say via page frontmatter?
|
|
const excludeFromResourceNameCheck = [
|
|
'endpoints-available-for-github-apps.md',
|
|
'permissions-required-for-github-apps.md',
|
|
'index.md'
|
|
]
|
|
|
|
describe('REST references docs', () => {
|
|
jest.setTimeout(3 * 60 * 1000)
|
|
|
|
test('markdown file exists for every operationId prefix in the api.github.com schema', async () => {
|
|
const { categories } = require('../../lib/rest')
|
|
const referenceDir = path.join(__dirname, '../../content/rest/reference')
|
|
const filenames = fs.readdirSync(referenceDir)
|
|
.filter(filename => !excludeFromResourceNameCheck.find(excludedFile => filename.endsWith(excludedFile)))
|
|
.map(filename => filename.replace('.md', ''))
|
|
|
|
const missingResource = 'Found a markdown file in content/rest/reference that is not represented by an OpenAPI REST operation category.'
|
|
expect(difference(filenames, categories), missingResource).toEqual([])
|
|
|
|
const missingFile = 'Found an OpenAPI REST operation category that is not represented by a markdown file in content/rest/reference.'
|
|
expect(difference(categories, filenames), missingFile).toEqual([])
|
|
})
|
|
|
|
test('loads api.github.com OpenAPI schema data', async () => {
|
|
const operations = await getJSON('/en/rest/reference/emojis?json=currentRestOperations')
|
|
expect(JSON.stringify(operations).includes('GitHub Enterprise')).toBe(false)
|
|
})
|
|
|
|
test('loads Enterprise OpenAPI schema data', async () => {
|
|
const operations = await getJSON(`/en/enterprise/${enterpriseServerReleases.oldestSupported}/user/rest/reference/emojis?json=currentRestOperations`)
|
|
const operation = operations.find(operation => operation.operationId === 'emojis/get')
|
|
expect(isPlainObject(operation)).toBe(true)
|
|
expect(operation.description).toContain('GitHub Enterprise')
|
|
})
|
|
|
|
test('no wrongly detected AppleScript syntax highlighting in schema data', async () => {
|
|
const { operations } = require('../../lib/rest')
|
|
expect(JSON.stringify(operations).includes('hljs language-applescript')).toBe(false)
|
|
})
|
|
})
|