1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Use test() instead of it() (#50151)

This commit is contained in:
Peter Bengtsson
2024-04-15 15:29:00 -04:00
committed by GitHub
parent ae6915b761
commit 4cf070e63a
25 changed files with 113 additions and 135 deletions

View File

@@ -4,8 +4,6 @@ import enterpriseServerReleases from '#src/versions/lib/enterprise-server-releas
import { get, getDOM } from '#src/tests/helpers/e2etest.js'
import { SURROGATE_ENUMS } from '#src/frame/middleware/set-fastly-surrogate-key.js'
jest.useFakeTimers({ legacyFakeTimers: true })
describe('enterprise deprecation', () => {
jest.setTimeout(60 * 1000)
@@ -189,7 +187,7 @@ describe('does not render survey prompt or contribution button', () => {
})
describe('JS and CSS assets', () => {
it('returns the expected CSS file > 2.18', async () => {
test('returns the expected CSS file > 2.18', async () => {
const result = await get('/enterprise/2.18/dist/index.css', {
headers: {
Referrer: '/en/enterprise/2.18',
@@ -203,7 +201,7 @@ describe('JS and CSS assets', () => {
expect(result.headers['surrogate-key']).toBe(SURROGATE_ENUMS.MANUAL)
})
it('returns the expected CSS file', async () => {
test('returns the expected CSS file', async () => {
const result = await get('/stylesheets/index.css', {
headers: {
Referrer: '/en/enterprise/2.13',
@@ -214,7 +212,7 @@ describe('JS and CSS assets', () => {
expect(result.headers['content-type']).toBe('text/css; charset=utf-8')
})
it('returns the expected JS file > 2.18 by using Referrer', async () => {
test('returns the expected JS file > 2.18 by using Referrer', async () => {
const result = await get('/enterprise/2.18/dist/index.js', {
headers: {
Referrer: '/en/enterprise/2.18',
@@ -225,7 +223,7 @@ describe('JS and CSS assets', () => {
expect(result.headers['content-type']).toBe('application/javascript; charset=utf-8')
})
it("cannot return the archived asset if there's no Referrer", async () => {
test("cannot return the archived asset if there's no Referrer", async () => {
const result = await get('/enterprise/2.18/dist/index.js', {
headers: {
// No Referrer header set at all.
@@ -234,7 +232,7 @@ describe('JS and CSS assets', () => {
expect(result.statusCode).toBe(404)
})
it('cannot return the archived asset if empty Referrer', async () => {
test('cannot return the archived asset if empty Referrer', async () => {
const result = await get('/enterprise/2.18/dist/index.js', {
headers: {
Referrer: '',
@@ -243,7 +241,7 @@ describe('JS and CSS assets', () => {
expect(result.statusCode).toBe(404)
})
it('returns the expected JS file', async () => {
test('returns the expected JS file', async () => {
const result = await get('/javascripts/index.js', {
headers: {
Referrer: '/en/enterprise/2.13',
@@ -254,7 +252,7 @@ describe('JS and CSS assets', () => {
expect(result.headers['content-type']).toBe('application/javascript; charset=utf-8')
})
it('returns the expected image', async () => {
test('returns the expected image', async () => {
const result = await get('/assets/images/octicons/hamburger.svg', {
headers: {
Referrer: '/en/enterprise/2.17',
@@ -265,7 +263,7 @@ describe('JS and CSS assets', () => {
expect(result.headers['content-type']).toBe('image/svg+xml; charset=utf-8')
})
it('returns the expected node_modules', async () => {
test('returns the expected node_modules', async () => {
const result = await get(
'/node_modules/instantsearch.js/dist/instantsearch.production.min.js',
{
@@ -279,7 +277,7 @@ describe('JS and CSS assets', () => {
expect(result.headers['content-type']).toBe('application/javascript; charset=utf-8')
})
it('returns the expected favicon', async () => {
test('returns the expected favicon', async () => {
const result = await get('/assets/images/site/favicon.svg', {
headers: {
Referrer: '/en/enterprise/2.18',
@@ -290,7 +288,7 @@ describe('JS and CSS assets', () => {
expect(result.headers['content-type']).toBe('image/svg+xml; charset=utf-8')
})
it('returns the expected CSS file ( <2.13 )', async () => {
test('returns the expected CSS file ( <2.13 )', async () => {
const result = await get('/assets/stylesheets/application.css', {
headers: {
Referrer: '/en/enterprise/2.12',
@@ -301,7 +299,7 @@ describe('JS and CSS assets', () => {
expect(result.headers['content-type']).toBe('text/css; charset=utf-8')
})
it('ignores invalid paths', async () => {
test('ignores invalid paths', async () => {
const result = await get('/pizza/index.css', {
headers: {
Referrer: '/en/enterprise/2.13',

View File

@@ -99,7 +99,7 @@ describe('archived enterprise static assets', () => {
afterAll(() => nock.cleanAll())
it('should proxy if the static asset is prefixed', async () => {
test('should proxy if the static asset is prefixed', async () => {
const req = mockRequest('/enterprise/2.21/_next/static/foo.css', {
headers: {
Referrer: '/enterprise/2.21',
@@ -115,7 +115,7 @@ describe('archived enterprise static assets', () => {
checkCachingHeaders(res, false, 60)
})
it('should proxy if the Referrer header indicates so on home page', async () => {
test('should proxy if the Referrer header indicates so on home page', async () => {
const req = mockRequest('/_next/static/only-on-proxy.css', {
headers: {
Referrer: '/enterprise/2.21',
@@ -131,7 +131,7 @@ describe('archived enterprise static assets', () => {
checkCachingHeaders(res, false, 60)
})
it('should proxy if the Referrer header indicates so on sub-page', async () => {
test('should proxy if the Referrer header indicates so on sub-page', async () => {
const req = mockRequest('/_next/static/only-on-2.3.css', {
headers: {
Referrer: '/en/enterprise-server@2.3/some/page',
@@ -147,7 +147,7 @@ describe('archived enterprise static assets', () => {
checkCachingHeaders(res, false, 60)
})
it('might still 404 even with the right referrer', async () => {
test('might still 404 even with the right referrer', async () => {
const req = mockRequest('/_next/static/fourofour.css', {
headers: {
Referrer: '/en/enterprise-server@2.3/some/page',
@@ -166,7 +166,7 @@ describe('archived enterprise static assets', () => {
expect(nexted).toBe(true)
})
it('404 on the proxy but actually present here', async () => {
test('404 on the proxy but actually present here', async () => {
const req = mockRequest('/assets/images/site/logo.png', {
headers: {
Referrer: '/en/enterprise-server@2.3/some/page',

View File

@@ -16,19 +16,19 @@ function getNextStaticAsset(directory) {
describe('static assets', () => {
jest.setTimeout(60 * 1000)
it('should serve /assets/cb-* with optimal headers', async () => {
test('should serve /assets/cb-* with optimal headers', async () => {
const res = await get('/assets/cb-1234/images/site/logo.png')
expect(res.statusCode).toBe(200)
checkCachingHeaders(res)
})
it('should serve /assets/ with optimal headers', async () => {
test('should serve /assets/ with optimal headers', async () => {
const res = await get('/assets/images/site/logo.png')
expect(res.statusCode).toBe(200)
checkCachingHeaders(res, true)
})
it('should serve /_next/static/ with optimal headers', async () => {
test('should serve /_next/static/ with optimal headers', async () => {
// This picks the first one found. We just need it to be anything
// that actually resolves.
const filePath = getNextStaticAsset('css')
@@ -38,26 +38,26 @@ describe('static assets', () => {
checkCachingHeaders(res)
})
it('should 404 on /assets/cb-* with plain text', async () => {
test('should 404 on /assets/cb-* with plain text', async () => {
const res = await get('/assets/cb-1234/never/heard/of.png')
expect(res.statusCode).toBe(404)
expect(res.headers['content-type']).toContain('text/plain')
// Only a tiny amount of Cache-Control on these
checkCachingHeaders(res, true, 60)
})
it('should 404 on /assets/ with plain text', async () => {
test('should 404 on /assets/ with plain text', async () => {
const res = await get('/assets/never/heard/of.png')
expect(res.statusCode).toBe(404)
expect(res.headers['content-type']).toContain('text/plain')
checkCachingHeaders(res, true, 60)
})
it('should 404 on /_next/static/ with plain text', async () => {
test('should 404 on /_next/static/ with plain text', async () => {
const res = await get('/_next/static/never/heard/of.css')
expect(res.statusCode).toBe(404)
expect(res.headers['content-type']).toContain('text/plain')
checkCachingHeaders(res, true, 60)
})
it("should redirect if the URLisn't all lowercase", async () => {
test("should redirect if the URLisn't all lowercase", async () => {
// Directory
{
const res = await get('/assets/images/SITE/logo.png')

View File

@@ -4,7 +4,7 @@ import {
} from '../../lib/index.js'
describe('audit log event fitering', () => {
it('matches single allowlist value', () => {
test('matches single allowlist value', () => {
const eventsToProcess = [
{
action: 'repo.create',
@@ -17,7 +17,7 @@ describe('audit log event fitering', () => {
expect(filteredEvents[0].action).toEqual('repo.create')
})
it('matches multiple allowlist values', () => {
test('matches multiple allowlist values', () => {
const eventsToProcess = [
{
action: 'repo.create',
@@ -36,7 +36,7 @@ describe('audit log event fitering', () => {
expect(filteredEvents.length).toEqual(2)
})
it('does not match non-matching allowlist value', () => {
test('does not match non-matching allowlist value', () => {
const eventsToProcess = [
{
action: 'repo.create',
@@ -49,7 +49,7 @@ describe('audit log event fitering', () => {
expect(filteredEvents.length).toBe(0)
})
it('ghes filters and updates multiple ghes versions', () => {
test('ghes filters and updates multiple ghes versions', () => {
const eventsToProcess = [
{
action: 'repo.create',
@@ -101,7 +101,7 @@ describe('audit log event fitering', () => {
expect(auditLogPage in currentEvents['ghes-3.12']).toBeFalsy()
})
it('gets the correct event fields data', () => {
test('gets the correct event fields data', () => {
const eventsToProcess = [
{
action: 'repo.create',

View File

@@ -33,11 +33,11 @@ describe('getChangelogItems module', () => {
afterAll(() => nock.cleanAll())
it('changelog contains 3 items', async () => {
test('changelog contains 3 items', async () => {
expect(changelog.length).toEqual(3)
})
it('each changelog item has expected title, date, and href', async () => {
test('each changelog item has expected title, date, and href', async () => {
const expectedChangelogValues = [
{
title: 'Authentication token format updates are generally available',

View File

@@ -1,7 +1,6 @@
import yaml from 'js-yaml'
import { readFile } from 'fs/promises'
import walk from 'walk-sync'
import { jest } from '@jest/globals'
import { liquid } from '#src/content-render/index.js'
@@ -13,8 +12,6 @@ const yamlWalkOptions = {
}
const yamlFileList = walk(learningTrackRootPath, yamlWalkOptions).sort()
jest.useFakeTimers({ legacyFakeTimers: true })
describe('lint learning tracks', () => {
if (yamlFileList.length < 1) return
@@ -26,7 +23,7 @@ describe('lint learning tracks', () => {
yamlContent = await yaml.load(fileContents)
})
it('contains valid liquid', () => {
test('contains valid liquid', () => {
const toLint = []
Object.values(yamlContent).forEach(({ title, description }) => {
toLint.push(title)

View File

@@ -5,13 +5,10 @@ import walk from 'walk-sync'
import { zip } from 'lodash-es'
import yaml from 'js-yaml'
import fs from 'fs/promises'
import { jest } from '@jest/globals'
import languages from '#src/languages/lib/languages.js'
import { getDiffFiles } from '../lib/diff-files.js'
jest.useFakeTimers({ legacyFakeTimers: true })
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const rootDir = path.join(__dirname, '../../..')

View File

@@ -1,4 +1,4 @@
import { afterAll, beforeAll, expect, describe, it } from '@jest/globals'
import { afterAll, beforeAll, expect, describe } from '@jest/globals'
import Page from '#src/frame/lib/page.js'
import languages from '#src/languages/lib/languages.js'
@@ -27,7 +27,7 @@ describe('data tag', () => {
languages.en.dir = enDirBefore
})
it('should render fine if data is found', async () => {
test('should render fine if data is found', async () => {
const page = await Page.init({
relativePath: 'liquid-tags/good-data-variable.md',
basePath: './src/fixtures/fixtures',
@@ -44,7 +44,7 @@ describe('data tag', () => {
// which we control the value of here in the test.
expect(rendered.includes('Foo')).toBeTruthy()
})
it('should throw if the data tag is used with something unrecognized', async () => {
test('should throw if the data tag is used with something unrecognized', async () => {
const page = await Page.init({
relativePath: 'liquid-tags/bad-data-variable.md',
basePath: './src/fixtures/fixtures',

View File

@@ -1,20 +1,20 @@
import { renderContent } from '#src/content-render/index.js'
describe('octicon tag', () => {
it('renders the expected octicon', async () => {
test('renders the expected octicon', async () => {
const actual = await renderContent('{% octicon "check" %}')
expect(actual).toContain('<svg ')
expect(actual).toContain('class="octicon octicon-check"')
})
it('renders the expected octicon with an option', async () => {
test('renders the expected octicon with an option', async () => {
const actual = await renderContent('{% octicon "check" width="64" %}')
expect(actual).toContain('<svg ')
expect(actual).toContain('class="octicon octicon-check"')
expect(actual).toContain('width="64"')
})
it('renders the expected octicon with multiple options', async () => {
test('renders the expected octicon with multiple options', async () => {
const actual = await renderContent('{% octicon "check" width="64" aria-label="A checkmark" %}')
expect(actual).toContain('<svg ')
expect(actual).toContain('class="octicon octicon-check"')
@@ -22,20 +22,20 @@ describe('octicon tag', () => {
expect(actual).toContain('aria-label="A checkmark"')
})
it('uses label to set aria-label', async () => {
test('uses label to set aria-label', async () => {
const actual = await renderContent('{% octicon "check" label="A checkmark" %}')
expect(actual).toContain('<svg ')
expect(actual).toContain('class="octicon octicon-check"')
expect(actual).toContain('aria-label="A checkmark"')
})
it('throws an error with invalid syntax', async () => {
test('throws an error with invalid syntax', async () => {
await expect(renderContent('{% octicon 123 %}')).rejects.toThrowError(
'Syntax Error in tag \'octicon\' - Valid syntax: octicon "<name>" <key="value">',
)
})
it('throws an error with a non-existant octicon', async () => {
test('throws an error with a non-existant octicon', async () => {
await expect(renderContent('{% octicon "pizza-patrol" %}')).rejects.toThrowError(
'Octicon pizza-patrol does not exist',
)

View File

@@ -11,7 +11,7 @@ describe('Hydro', () => {
nock.cleanAll()
})
it('publishes a single event', async () => {
test('publishes a single event', async () => {
const scope = nock(endpoint, {
reqheaders: {
Authorization: /^Hydro \w{64}$/,
@@ -33,7 +33,7 @@ describe('Hydro', () => {
expect(scope.isDone()).toBeTruthy()
})
it('publishes many events in one request', async () => {
test('publishes many events in one request', async () => {
const scope = nock(endpoint, {
reqheaders: {
Authorization: /^Hydro \w{64}$/,
@@ -66,7 +66,7 @@ describe('Hydro', () => {
expect(scope.isDone()).toBeTruthy()
})
it('422 with JSON error', async () => {
test('422 with JSON error', async () => {
// Hydro will return 422 errors with the body being a string of
// JSON serialized information. Some of the errors are operational
// and something we don't need to send to Failbot.

View File

@@ -13,7 +13,7 @@ expect.extend({
})
describe('formatErrors', () => {
it('should produce objects that match the validation spec', () => {
test('should produce objects that match the validation spec', () => {
// Produce an error
const { errors } = validateJson({ type: 'string' }, 0)
const formattedErrors = formatErrors(errors, '')

View File

@@ -46,18 +46,18 @@ describe('POST /events', () => {
},
}
it('should record a page event', async () => {
test('should record a page event', async () => {
const { statusCode } = await checkEvent(pageExample)
expect(statusCode).toBe(200)
})
it('should require a type', async () => {
test('should require a type', async () => {
const { statusCode, body } = await checkEvent({ ...pageExample, type: undefined })
expect(statusCode).toBe(400)
expect(body).toEqual('{"message":"Invalid type"}')
})
it('should require an event_id in uuid', async () => {
test('should require an event_id in uuid', async () => {
const { statusCode } = await checkEvent({
...pageExample,
context: {
@@ -68,7 +68,7 @@ describe('POST /events', () => {
expect(statusCode).toBe(400)
})
it('should require a user in uuid', async () => {
test('should require a user in uuid', async () => {
const { statusCode } = await checkEvent({
...pageExample,
context: {
@@ -79,7 +79,7 @@ describe('POST /events', () => {
expect(statusCode).toBe(400)
})
it('should require a version', async () => {
test('should require a version', async () => {
const { statusCode } = await checkEvent({
...pageExample,
context: {
@@ -90,7 +90,7 @@ describe('POST /events', () => {
expect(statusCode).toBe(400)
})
it('should require created timestamp', async () => {
test('should require created timestamp', async () => {
const { statusCode } = await checkEvent({
...pageExample,
context: {
@@ -101,7 +101,7 @@ describe('POST /events', () => {
expect(statusCode).toBe(400)
})
it('should not allow a honeypot token', async () => {
test('should not allow a honeypot token', async () => {
const { statusCode } = await checkEvent({
...pageExample,
context: {

View File

@@ -1,7 +1,7 @@
import { parseUserAgent } from '../components/user-agent.ts'
describe('parseUserAgent', () => {
it('android, chrome', () => {
test('android, chrome', () => {
const ua =
'Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36'
const { os, browser } = parseUserAgent(ua)
@@ -9,7 +9,7 @@ describe('parseUserAgent', () => {
expect(browser).toBe('chrome')
})
it('ios, safari', () => {
test('ios, safari', () => {
const ua =
'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1'
const { os, browser } = parseUserAgent(ua)
@@ -17,7 +17,7 @@ describe('parseUserAgent', () => {
expect(browser).toBe('safari')
})
it('windows, edge', () => {
test('windows, edge', () => {
const ua =
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
const { os, browser } = parseUserAgent(ua)
@@ -25,7 +25,7 @@ describe('parseUserAgent', () => {
expect(browser).toBe('edge')
})
it('mac, edge', () => {
test('mac, edge', () => {
const ua =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203'
const { os, browser } = parseUserAgent(ua)
@@ -33,7 +33,7 @@ describe('parseUserAgent', () => {
expect(browser).toBe('edge')
})
it('mac, safari', () => {
test('mac, safari', () => {
const ua =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'
const { os, browser } = parseUserAgent(ua)
@@ -41,7 +41,7 @@ describe('parseUserAgent', () => {
expect(browser).toBe('safari')
})
it('windows, chrome', () => {
test('windows, chrome', () => {
const ua =
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36'
const { os, browser } = parseUserAgent(ua)
@@ -49,14 +49,14 @@ describe('parseUserAgent', () => {
expect(browser).toBe('chrome')
})
it('linux, firefox', () => {
test('linux, firefox', () => {
const ua = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1'
const { os, browser } = parseUserAgent(ua)
expect(os).toBe('linux')
expect(browser).toBe('firefox')
})
it('mac, opera', () => {
test('mac, opera', () => {
const ua =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 OPR/101.0.0.0'
const { os, browser } = parseUserAgent(ua)
@@ -64,7 +64,7 @@ describe('parseUserAgent', () => {
expect(browser).toBe('opera')
})
it('other, other', () => {
test('other, other', () => {
const ua = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
const { os, browser } = parseUserAgent(ua)
expect(os).toBe('other')

View File

@@ -7,13 +7,13 @@ function allowIndex(path) {
}
describe('block robots', () => {
it('allows crawling of the homepage and English content', async () => {
test('allows crawling of the homepage and English content', async () => {
expect(allowIndex('/')).toBe(true)
expect(allowIndex('/en')).toBe(true)
expect(allowIndex('/en/articles/verifying-your-email-address')).toBe(true)
})
it('disallows crawling of WIP products', async () => {
test('disallows crawling of WIP products', async () => {
const wipProductIds = Object.values(productMap)
.filter((product) => product.wip)
.map((product) => product.id)
@@ -34,7 +34,7 @@ describe('block robots', () => {
})
})
it('disallows crawling of early access "hidden" products', async () => {
test('disallows crawling of early access "hidden" products', async () => {
const hiddenProductIds = Object.values(productMap)
.filter((product) => product.hidden)
.map((product) => product.id)
@@ -53,7 +53,7 @@ describe('block robots', () => {
})
})
it('allows crawling of non-WIP products', async () => {
test('allows crawling of non-WIP products', async () => {
expect('actions' in productMap).toBe(true)
expect(allowIndex('/en/actions')).toBe(true)
expect(allowIndex('/en/actions/overview')).toBe(true)
@@ -64,7 +64,7 @@ describe('block robots', () => {
).toBe(true)
})
it('disallows crawling of deprecated enterprise releases', async () => {
test('disallows crawling of deprecated enterprise releases', async () => {
enterpriseServerReleases.deprecated.forEach((version) => {
const blockedPaths = [
`/en/enterprise-server@${version}/actions`,

View File

@@ -262,7 +262,7 @@ describe('Page class', () => {
})
})
it('includes videos specified in the featuredLinks frontmatter', async () => {
test('includes videos specified in the featuredLinks frontmatter', async () => {
expect(page.featuredLinks.videos).toStrictEqual([
{
title: 'codespaces',
@@ -283,7 +283,7 @@ describe('Page class', () => {
})
describe('introLinks', () => {
it('includes the links specified in the introLinks frontmatter', async () => {
test('includes the links specified in the introLinks frontmatter', async () => {
const page = await Page.init({
relativePath: 'article-with-introLinks.md',
basePath: path.join(__dirname, '../../../src/fixtures/fixtures'),
@@ -298,7 +298,7 @@ describe('Page class', () => {
})
describe('Page.parseFrontmatter()', () => {
it('throws an error on bad input', () => {
test('throws an error on bad input', () => {
const markdown = null
expect(() => {
Page.parseFrontmatter('some/file.md', markdown)

View File

@@ -18,7 +18,7 @@ versions:
`
describe('frontmatter', () => {
it('parses frontmatter and content in a given string (no options required)', () => {
test('parses frontmatter and content in a given string (no options required)', () => {
const { data, content, errors } = parse(fixture1)
expect(data.title).toBe('Hello, World')
expect(data.meaning_of_life).toBe(42)
@@ -27,13 +27,13 @@ describe('frontmatter', () => {
})
describe('frontmatter.stringify', () => {
it('is exported', () => {
test('is exported', () => {
expect(typeof parse.stringify).toBe('function')
})
})
describe('YML parsing errors', () => {
it('creates errors if YML has an unescaped quote', () => {
test('creates errors if YML has an unescaped quote', () => {
const fixture = `---
intro: 'I've got an unescaped quote'
---
@@ -50,7 +50,7 @@ I am content.
expect(errors[0]).toEqual(expectedError)
})
it('creates errors if YML has incorrect indentation', () => {
test('creates errors if YML has incorrect indentation', () => {
const fixture = `---
title: Hello, World
intro: 'I have a bad leading space'
@@ -70,7 +70,7 @@ I am content.
})
describe('schema', () => {
it('is optional', () => {
test('is optional', () => {
const schema = {
properties: {
title: {
@@ -89,7 +89,7 @@ I am content.
expect(errors.length).toBe(0)
})
it('creates errors if frontmatter does not conform to schema', () => {
test('creates errors if frontmatter does not conform to schema', () => {
const schema = {
properties: {
meaning_of_life: {
@@ -117,7 +117,7 @@ I am content.
expect(errors[0]).toEqual(expectedError)
})
it('creates errors if versions frontmatter does not match semver format', () => {
test('creates errors if versions frontmatter does not match semver format', () => {
const schema = { type: 'object', required: ['versions'], properties: {} }
schema.properties.versions = Object.assign({}, frontmatterSchema.properties.versions)
@@ -146,7 +146,7 @@ I am content.
expect(errors[0]).toEqual(expectedError)
})
it('creates errors if required frontmatter is not present', () => {
test('creates errors if required frontmatter is not present', () => {
const schema = {
type: 'object',
required: ['yet_another_key'],

View File

@@ -11,8 +11,6 @@ import { describe, jest } from '@jest/globals'
const AZURE_STORAGE_URL = 'githubdocs.azureedge.net'
jest.useFakeTimers({ legacyFakeTimers: true })
describe('server', () => {
jest.setTimeout(60 * 1000)
@@ -269,7 +267,7 @@ describe('server', () => {
})
describe('static routes', () => {
it('serves content from the /assets directory', async () => {
test('serves content from the /assets directory', async () => {
const res = await get('/assets/images/site/be-social.gif')
expect(res.statusCode).toBe(200)
expect(res.headers['cache-control']).toContain('public')
@@ -283,7 +281,7 @@ describe('static routes', () => {
expect(res.headers['last-modified']).toBeTruthy()
})
it('rewrites /assets requests from a cache-busting prefix', async () => {
test('rewrites /assets requests from a cache-busting prefix', async () => {
// The rewrite-asset-urls.js Markdown plugin will do this to img tags.
const res = await get('/assets/cb-123456/images/site/be-social.gif')
expect(res.statusCode).toBe(200)
@@ -293,7 +291,7 @@ describe('static routes', () => {
expect(res.headers['surrogate-key']).toBe(SURROGATE_ENUMS.MANUAL)
})
it('no manual surrogate key for /assets requests without caching-busting prefix', async () => {
test('no manual surrogate key for /assets requests without caching-busting prefix', async () => {
const res = await get('/assets/images/site/be-social.gif')
expect(res.statusCode).toBe(200)
expect(res.headers['set-cookie']).toBeUndefined()
@@ -305,7 +303,7 @@ describe('static routes', () => {
expect(surrogateKeySplit.includes(makeLanguageSurrogateKey())).toBeTruthy()
})
it('serves schema files from the /data/graphql directory at /public', async () => {
test('serves schema files from the /data/graphql directory at /public', async () => {
const res = await get('/public/schema.docs.graphql')
expect(res.statusCode).toBe(200)
expect(res.headers['cache-control']).toContain('public')

View File

@@ -20,7 +20,7 @@ describe('creating a changelog from old schema and new schema', () => {
MockDate.reset()
})
it('finds a diff of schema changes, upcoming changes, and preview changes', async () => {
test('finds a diff of schema changes, upcoming changes, and preview changes', async () => {
const oldSchemaString = `
type PreviewType {
field1(changeTypeArgument: Int): Int
@@ -94,7 +94,7 @@ upcoming_changes:
expect(entry).toEqual(expectedChangelogEntry)
})
it('returns null when there isnt any difference', async () => {
test('returns null when there isnt any difference', async () => {
const schemaString = `
type Query {
i: Int!
@@ -106,7 +106,7 @@ upcoming_changes:
})
describe('Preparing preview links', () => {
it('fixes preview names', () => {
test('fixes preview names', () => {
// These two are special cases
expect(cleanPreviewTitle('UpdateRefsPreview')).toEqual('Update refs preview')
expect(cleanPreviewTitle('MergeInfoPreview')).toEqual('Merge info preview')
@@ -116,7 +116,7 @@ describe('Preparing preview links', () => {
expect(cleanPreviewTitle('nice preview')).toEqual('nice preview')
})
it('creates anchors from preview titles', () => {
test('creates anchors from preview titles', () => {
expect(previewAnchor('Merge info preview')).toEqual('merge-info-preview')
expect(previewAnchor('some.punct123 preview')).toEqual('somepunct123-preview')
})
@@ -127,7 +127,7 @@ describe('updating the changelog file', () => {
MockDate.reset()
})
it('modifies the entry object and the file on disk', async () => {
test('modifies the entry object and the file on disk', async () => {
const testTargetPath = 'src/graphql/tests/fixtures/example-changelog.json'
const previousContents = await fs.readFile(testTargetPath)

View File

@@ -24,13 +24,13 @@ describe('FailBot', () => {
})
describe('.report', () => {
it('returns early if `HAYSTACK_URL` is not set', async () => {
test('returns early if `HAYSTACK_URL` is not set', async () => {
const result = await FailBot.report()
expect(result).toBeUndefined()
expect(requestBodiesSent.length).toBe(0)
})
it('sends the expected report', async () => {
test('sends the expected report', async () => {
process.env.HAYSTACK_URL = 'https://haystack.example.com'
const err = new Error('Kaboom')
const backendPromises = FailBot.report(err, { foo: 'bar' })

View File

@@ -4,8 +4,6 @@ import enterpriseServerReleases from '#src/versions/lib/enterprise-server-releas
import { get } from '#src/tests/helpers/e2etest.js'
import readJsonFile from '#src/frame/lib/read-json-file.js'
jest.useFakeTimers({ legacyFakeTimers: true })
describe('developer redirects', () => {
jest.setTimeout(10 * 60 * 1000)

View File

@@ -2,8 +2,6 @@ import { jest } from '@jest/globals'
import { head } from '#src/tests/helpers/e2etest.js'
jest.useFakeTimers({ legacyFakeTimers: true })
describe('developer.github.com redirects', () => {
jest.setTimeout(60 * 1000)

View File

@@ -7,10 +7,11 @@ import {
supported,
oldestSupported,
} from '#src/versions/lib/enterprise-server-releases.js'
const previousEnterpriserServerVersion = supported[1]
describe('getRedirect basics', () => {
it('should sometimes not correct the version prefix', () => {
test('should sometimes not correct the version prefix', () => {
// This essentially tests legacy entries that come from the
// `developer.json` file. Normally, we would have first
// rewritten `/enterprise/3.0` to `/enterprise-server@3.0`
@@ -27,7 +28,7 @@ describe('getRedirect basics', () => {
expect(getRedirect(uri, ctx)).toBe('/en/something/else')
})
it('should return undefined if nothing could be found', () => {
test('should return undefined if nothing could be found', () => {
const ctx = {
pages: {},
redirects: {},
@@ -35,7 +36,7 @@ describe('getRedirect basics', () => {
expect(getRedirect('/foo/pizza', ctx)).toBeUndefined()
})
it('should just inject language on version "home pages"', () => {
test('should just inject language on version "home pages"', () => {
const ctx = {
pages: {},
redirects: {},
@@ -52,7 +53,7 @@ describe('getRedirect basics', () => {
expect(getRedirect('/enterprise-server', ctx)).toBe(`/en/enterprise-server@${latestStable}`)
})
it('should always "remove" the free-pro-team prefix', () => {
test('should always "remove" the free-pro-team prefix', () => {
const ctx = {
pages: {},
redirects: {
@@ -67,7 +68,7 @@ describe('getRedirect basics', () => {
expect(getRedirect('/free-pro-team@latest/github', ctx)).toBe('/en/github')
})
it('should handle some odd exceptions', () => {
test('should handle some odd exceptions', () => {
const ctx = {
pages: {},
redirects: {},
@@ -84,7 +85,7 @@ describe('getRedirect basics', () => {
)
})
it('should figure out redirect based on presence of pages in certain cases', () => {
test('should figure out redirect based on presence of pages in certain cases', () => {
const ctx = {
pages: {
[`/en/enterprise-server@${previousEnterpriserServerVersion}/foo/bar`]: null,
@@ -104,7 +105,7 @@ describe('getRedirect basics', () => {
).toBe(`/en/enterprise-server@${previousEnterpriserServerVersion}/admin/github-management`)
})
it('should always correct the old enterprise prefix', () => {
test('should always correct the old enterprise prefix', () => {
const ctx = {
pages: {},
redirects: {
@@ -129,7 +130,7 @@ describe('getRedirect basics', () => {
)
})
it('should not do anything on some prefixes', () => {
test('should not do anything on some prefixes', () => {
const ctx = {
pages: {},
redirects: {},
@@ -140,7 +141,7 @@ describe('getRedirect basics', () => {
expect(getRedirect(`/en/enterprise-cloud@latest/user/foo`, ctx)).toBeUndefined()
})
it('should redirect both the prefix and the path needs to change', () => {
test('should redirect both the prefix and the path needs to change', () => {
const ctx = {
pages: {},
redirects: {
@@ -155,7 +156,7 @@ describe('getRedirect basics', () => {
)
})
it('should work for some deprecated enterprise-server URLs too', () => {
test('should work for some deprecated enterprise-server URLs too', () => {
// Starting with enterprise-server 3.0, we have made redirects become
// a *function* rather than a lookup on a massive object.
const ctx = {
@@ -168,7 +169,7 @@ describe('getRedirect basics', () => {
})
describe('github-ae@latest', () => {
it('home page should redirect to enterprise-cloud home page', () => {
test('home page should redirect to enterprise-cloud home page', () => {
const ctx = {
pages: {},
redirects: {},
@@ -176,7 +177,7 @@ describe('github-ae@latest', () => {
expect(getRedirect('/github-ae@latest', ctx)).toBe('/en/enterprise-cloud@latest')
expect(getRedirect('/en/github-ae@latest', ctx)).toBe('/en/enterprise-cloud@latest')
})
it('should redirect to home page for admin/release-notes', () => {
test('should redirect to home page for admin/release-notes', () => {
const ctx = {
pages: {},
redirects: {},
@@ -184,7 +185,7 @@ describe('github-ae@latest', () => {
expect(getRedirect('/github-ae@latest/admin/release-notes', ctx)).toBe('/en')
expect(getRedirect('/en/github-ae@latest/admin/release-notes', ctx)).toBe('/en')
})
it('a page that does exits, without correction, in enterprise-cloud', () => {
test('a page that does exits, without correction, in enterprise-cloud', () => {
const ctx = {
pages: {
'/en/enterprise-cloud@latest/foo': null,
@@ -194,7 +195,7 @@ describe('github-ae@latest', () => {
expect(getRedirect('/github-ae@latest/foo', ctx)).toBe('/en/enterprise-cloud@latest/foo')
expect(getRedirect('/en/github-ae@latest/foo', ctx)).toBe('/en/enterprise-cloud@latest/foo')
})
it("a page that doesn't exist in enterprise-cloud but in FPT", () => {
test("a page that doesn't exist in enterprise-cloud but in FPT", () => {
const ctx = {
pages: {
'/en/foo': true,
@@ -204,7 +205,7 @@ describe('github-ae@latest', () => {
expect(getRedirect('/github-ae@latest/foo', ctx)).toBe('/en/foo')
expect(getRedirect('/en/github-ae@latest/foo', ctx)).toBe('/en/foo')
})
it("a page that doesn't exist in enterprise-cloud or in FPT", () => {
test("a page that doesn't exist in enterprise-cloud or in FPT", () => {
const ctx = {
pages: {
'/en/foo': true,
@@ -214,7 +215,7 @@ describe('github-ae@latest', () => {
expect(getRedirect('/github-ae@latest/bar', ctx)).toBe('/en')
expect(getRedirect('/en/github-ae@latest/bar', ctx)).toBe('/en')
})
it('a URL with legacy redirects, that redirects to enterprise-cloud', () => {
test('a URL with legacy redirects, that redirects to enterprise-cloud', () => {
const ctx = {
pages: {
'/en/foo': true,
@@ -227,7 +228,7 @@ describe('github-ae@latest', () => {
expect(getRedirect('/github-ae@latest/food', ctx)).toBe('/en/enterprise-cloud@latest/foo')
expect(getRedirect('/en/github-ae@latest/food', ctx)).toBe('/en/enterprise-cloud@latest/foo')
})
it("a URL with legacy redirects, that can't redirect to enterprise-cloud", () => {
test("a URL with legacy redirects, that can't redirect to enterprise-cloud", () => {
const ctx = {
pages: {
'/en/foo': true,
@@ -240,7 +241,7 @@ describe('github-ae@latest', () => {
expect(getRedirect('/github-ae@latest/food', ctx)).toBe('/en/foo')
expect(getRedirect('/en/github-ae@latest/food', ctx)).toBe('/en/foo')
})
it('should 404 if nothing matches at all', () => {
test('should 404 if nothing matches at all', () => {
const ctx = {
pages: {},
redirects: {},

View File

@@ -4,8 +4,6 @@ import nock from 'nock'
import { get, getDOM } from '#src/tests/helpers/e2etest.js'
import enterpriseServerReleases from '#src/versions/lib/enterprise-server-releases.js'
jest.useFakeTimers({ legacyFakeTimers: true })
describe('release notes', () => {
jest.setTimeout(60 * 1000)
@@ -29,13 +27,13 @@ describe('release notes', () => {
afterAll(() => nock.cleanAll())
it('redirects to the release notes on enterprise.github.com if none are present for this version here', async () => {
test('redirects to the release notes on enterprise.github.com if none are present for this version here', async () => {
const res = await get('/en/enterprise-server@2.19/admin/release-notes')
expect(res.statusCode).toBe(302)
expect(res.headers.location).toBe('https://enterprise.github.com/releases/2.19.0/notes')
})
it("renders the release-notes layout if this version's release notes are in this repo", async () => {
test("renders the release-notes layout if this version's release notes are in this repo", async () => {
const oldestSupportedGhes = enterpriseServerReleases.oldestSupported
const res = await get(`/en/enterprise-server@${oldestSupportedGhes}/admin/release-notes`)
expect(res.statusCode).toBe(200)
@@ -46,19 +44,19 @@ describe('release notes', () => {
).toBe(true)
})
it('404 if a bogus version is requested', async () => {
test('404 if a bogus version is requested', async () => {
const res = await get('/en/enterprise-server@12345/admin/release-notes')
expect(res.statusCode).toBe(404)
})
it('404 if a the pathname only ends with the /release-notes', async () => {
test('404 if a the pathname only ends with the /release-notes', async () => {
const res = await get(`/en/enterprise-server@latest/ANY/release-notes`, {
followAllRedirects: true,
})
expect(res.statusCode).toBe(404)
})
it('404 if a the pathname only ends with the /admin', async () => {
test('404 if a the pathname only ends with the /admin', async () => {
const res = await get(`/en/enterprise-server@latest/ANY/admin`, {
followAllRedirects: true,
})

View File

@@ -2,7 +2,6 @@ import yaml from 'js-yaml'
import { readFile } from 'fs/promises'
import walk from 'walk-sync'
import path from 'path'
import { jest } from '@jest/globals'
import { liquid } from '#src/content-render/index.js'
@@ -14,8 +13,6 @@ const yamlWalkOptions = {
}
const yamlFileList = walk(ghesReleaseNoteRootPath, yamlWalkOptions).sort()
jest.useFakeTimers({ legacyFakeTimers: true })
describe('lint enterprise release notes', () => {
if (yamlFileList.length < 1) return
describe.each(yamlFileList)('%s', (yamlAbsPath) => {
@@ -27,7 +24,7 @@ describe('lint enterprise release notes', () => {
yamlContent = yaml.load(fileContents)
})
it('contains valid liquid', () => {
test('contains valid liquid', () => {
const { intro, sections } = yamlContent
let toLint = { intro }
for (const key in sections) {
@@ -51,7 +48,7 @@ describe('lint enterprise release notes', () => {
})
const currentWeeksFound = []
it('does not have more than one yaml file with currentWeek set to true', () => {
test('does not have more than one yaml file with currentWeek set to true', () => {
if (!yamlAbsPath.includes('data/release-notes/github-ae')) return
if (yamlContent.currentWeek) currentWeeksFound.push(relativePath)
const errorMessage = `Found more than one file with currentWeek set to true: ${currentWeeksFound.join(

View File

@@ -1,5 +1,3 @@
import { jest } from '@jest/globals'
import { getJsonValidator } from '#src/tests/lib/validate-json-schema.js'
import { allVersions } from '#src/versions/lib/all-versions.js'
import { latest } from '#src/versions/lib/enterprise-server-releases.js'
@@ -7,8 +5,6 @@ import schema from '#src/tests/helpers/schemas/versions-schema.js'
import nonEnterpriseDefaultVersion from '#src/versions/lib/non-enterprise-default-version.js'
import { formatAjvErrors } from '#src/tests/helpers/schemas.js'
jest.useFakeTimers({ legacyFakeTimers: true })
const validate = getJsonValidator(schema)
describe('versions module', () => {