Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahs committed Jan 14, 2021
1 parent affbc80 commit 9809627
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 68 deletions.
7 changes: 3 additions & 4 deletions tests/content/featured-links.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { getDOM, getJSON } = require('../helpers/supertest')
const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
const japaneseCharacters = require('japanese-characters')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')

describe('featuredLinks', () => {
jest.setTimeout(3 * 60 * 1000)
Expand All @@ -16,11 +15,11 @@ describe('featuredLinks', () => {
const $ = await getDOM('/en')
const $featuredLinks = $('.featured-links a')
expect($featuredLinks).toHaveLength(9)
expect($featuredLinks.eq(0).attr('href')).toBe(`/en/github/getting-started-with-github/set-up-git`)
expect($featuredLinks.eq(0).attr('href')).toBe('/en/github/getting-started-with-github/set-up-git')
expect($featuredLinks.eq(0).children('h4').text().startsWith('Set up Git')).toBe(true)
expect($featuredLinks.eq(0).children('p').text().startsWith('At the heart of GitHub')).toBe(true)

expect($featuredLinks.eq(8).attr('href')).toBe(`/en/github/working-with-github-pages`)
expect($featuredLinks.eq(8).attr('href')).toBe('/en/github/working-with-github-pages')
expect($featuredLinks.eq(8).children('h4').text().startsWith('GitHub Pages')).toBe(true)
expect($featuredLinks.eq(8).children('p').text().startsWith('You can create a website')).toBe(true)
})
Expand Down Expand Up @@ -58,7 +57,7 @@ describe('featuredLinks', () => {
test('returns modified array of links', async () => {
const gettingStartedLinks = await getJSON('/en?json=featuredLinks.gettingStarted')
const expectedFirstLink = {
href: `/en/github/getting-started-with-github/set-up-git`,
href: '/en/github/getting-started-with-github/set-up-git',
title: 'Set up Git'
}
expect(gettingStartedLinks[0].href).toEqual(expectedFirstLink.href)
Expand Down
6 changes: 3 additions & 3 deletions tests/content/site-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ describe('siteTree', () => {
test('object order', () => {
expect(Object.keys(siteTree)[0]).toBe('en')
expect(Object.keys(siteTree.en)[0]).toBe(nonEnterpriseDefaultVersion)
expect(Object.keys(siteTree.en[nonEnterpriseDefaultVersion].products.github.categories)[0]).toBe(`/en/github/getting-started-with-github`)
expect(Object.keys(siteTree.en[nonEnterpriseDefaultVersion].products.github.categories)[0]).toBe('/en/github/getting-started-with-github')
})

test('object structure', () => {
expect(nonEnterpriseDefaultVersion in siteTree.en).toBe(true)
expect(`enterprise-server@${latestEnterpriseRelease}` in siteTree.en).toBe(true)
expect(flatTree[`en.${nonEnterpriseDefaultVersion}.products.github.href`]).toBe(`/en/github`)
expect(flatTree[`en.${nonEnterpriseDefaultVersion}.products.github.categories./en/github/getting-started-with-github.href`]).toBe(`/en/github/getting-started-with-github`)
expect(flatTree[`en.${nonEnterpriseDefaultVersion}.products.github.href`]).toBe('/en/github')
expect(flatTree[`en.${nonEnterpriseDefaultVersion}.products.github.categories./en/github/getting-started-with-github.href`]).toBe('/en/github/getting-started-with-github')
})

describe('localized titles', () => {
Expand Down
31 changes: 15 additions & 16 deletions tests/rendering/breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { getDOM, getJSON } = require('../helpers/supertest')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')

const describeInternalOnly = process.env.GITHUB_REPOSITORY === 'github/docs-internal' ? describe : describe.skip

Expand Down Expand Up @@ -52,13 +51,13 @@ describe('breadcrumbs', () => {
test('English breadcrumbs link to English pages', async () => {
const $ = await getDOM('/en/github/getting-started-with-github')
const $breadcrumbs = $('.breadcrumbs a')
expect($breadcrumbs.eq(0).attr('href')).toBe(`/en/github`)
expect($breadcrumbs.eq(0).attr('href')).toBe('/en/github')
})

test('localized breadcrumbs link to localize pages', async () => {
const $ = await getDOM('/ja/github/getting-started-with-github')
const $breadcrumbs = $('.breadcrumbs a')
expect($breadcrumbs.eq(0).attr('href')).toBe(`/ja/github`)
expect($breadcrumbs.eq(0).attr('href')).toBe('/ja/github')
})
})

Expand Down Expand Up @@ -88,7 +87,7 @@ describe('breadcrumbs', () => {
const breadcrumbs = await getJSON('/en/github?json=breadcrumbs')
const expected = {
product: {
href: `/en/github`,
href: '/en/github',
title: 'GitHub.com'
}
}
Expand All @@ -99,11 +98,11 @@ describe('breadcrumbs', () => {
const breadcrumbs = await getJSON('/en/github/authenticating-to-github?json=breadcrumbs')
const expected = {
product: {
href: `/en/github`,
href: '/en/github',
title: 'GitHub.com'
},
category: {
href: `/en/github/authenticating-to-github`,
href: '/en/github/authenticating-to-github',
title: 'Authentication'
}
}
Expand All @@ -114,15 +113,15 @@ describe('breadcrumbs', () => {
const breadcrumbs = await getJSON('/en/github/authenticating-to-github/keeping-your-account-and-data-secure?json=breadcrumbs')
const expected = {
product: {
href: `/en/github`,
href: '/en/github',
title: 'GitHub.com'
},
category: {
href: `/en/github/authenticating-to-github`,
href: '/en/github/authenticating-to-github',
title: 'Authentication'
},
maptopic: {
href: `/en/github/authenticating-to-github/keeping-your-account-and-data-secure`,
href: '/en/github/authenticating-to-github/keeping-your-account-and-data-secure',
title: 'Keeping your account and data secure'
}
}
Expand All @@ -133,19 +132,19 @@ describe('breadcrumbs', () => {
const breadcrumbs = await getJSON('/en/github/authenticating-to-github/creating-a-strong-password?json=breadcrumbs')
const expected = {
product: {
href: `/en/github`,
href: '/en/github',
title: 'GitHub.com'
},
category: {
href: `/en/github/authenticating-to-github`,
href: '/en/github/authenticating-to-github',
title: 'Authentication'
},
maptopic: {
href: `/en/github/authenticating-to-github/keeping-your-account-and-data-secure`,
href: '/en/github/authenticating-to-github/keeping-your-account-and-data-secure',
title: 'Keeping your account and data secure'
},
article: {
href: `/en/github/authenticating-to-github/creating-a-strong-password`,
href: '/en/github/authenticating-to-github/creating-a-strong-password',
title: 'Creating a strong password'
}
}
Expand All @@ -156,15 +155,15 @@ describe('breadcrumbs', () => {
const breadcrumbs = await getJSON('/github/site-policy/github-privacy-statement?json=breadcrumbs')
const expected = {
product: {
href: `/en/github`,
href: '/en/github',
title: 'GitHub.com'
},
category: {
href: `/en/github/site-policy`,
href: '/en/github/site-policy',
title: 'Site policy'
},
article: {
href: `/en/github/site-policy/github-privacy-statement`,
href: '/en/github/site-policy/github-privacy-statement',
title: 'GitHub Privacy Statement'
}
}
Expand Down
11 changes: 5 additions & 6 deletions tests/rendering/header.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { getDOM } = require('../helpers/supertest')
const { oldestSupported, latest } = require('../../lib/enterprise-server-releases')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')

describe('header', () => {
jest.setTimeout(5 * 60 * 1000)
Expand All @@ -22,7 +21,7 @@ describe('header', () => {
describe('language links', () => {
test('lead to the same page in a different language', async () => {
const $ = await getDOM('/en/github/administering-a-repository/enabling-required-status-checks')
expect($(`#languages-selector a[href="/ja/github/administering-a-repository/enabling-required-status-checks"]`).length).toBe(1)
expect($('#languages-selector a[href="/ja/github/administering-a-repository/enabling-required-status-checks"]').length).toBe(1)
})

test('display the native name and the English name for each translated language', async () => {
Expand Down Expand Up @@ -68,7 +67,7 @@ describe('header', () => {
test('include github and admin, and emphasize the current product', async () => {
const $ = await getDOM('/en/articles/enabling-required-status-checks')

const github = $(`#homepages a.active[href="/en/github"]`)
const github = $('#homepages a.active[href="/en/github"]')
expect(github.length).toBe(1)
expect(github.text().trim()).toBe('GitHub.com')
expect(github.attr('class').includes('active')).toBe(true)
Expand All @@ -82,15 +81,15 @@ describe('header', () => {
test('point to homepages in the current page\'s language', async () => {
const $ = await getDOM('/ja/articles/enabling-required-status-checks')

expect($(`#homepages a.active[href="/ja/github"]`).length).toBe(1)
expect($('#homepages a.active[href="/ja/github"]').length).toBe(1)
expect($(`#homepages a[href="/ja/enterprise-server@${latest}/admin"]`).length).toBe(1)
})

test('emphasizes the product that corresponds to the current page', async () => {
const $ = await getDOM(`/en/enterprise/${oldestSupported}/user/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address`)
expect($(`#homepages a.active[href="/en/enterprise-server@${latest}/admin"]`).length).toBe(0)
expect($(`#homepages a[href="/en/github"]`).length).toBe(1)
expect($(`#homepages a.active[href="/en/github"]`).length).toBe(1)
expect($('#homepages a[href="/en/github"]').length).toBe(1)
expect($('#homepages a.active[href="/en/github"]').length).toBe(1)
})
})
})
29 changes: 14 additions & 15 deletions tests/rendering/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
const { get, getDOM, head } = require('../helpers/supertest')
const { describeViaActionsOnly } = require('../helpers/conditional-runs')
const path = require('path')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
const { loadPages } = require('../../lib/pages')

describe('server', () => {
Expand Down Expand Up @@ -214,7 +213,7 @@ describe('server', () => {

test('displays links to categories on product TOCs', async () => {
const $ = await getDOM('/en/github')
expect($(`article a[href="/en/github/getting-started-with-github"]`)).toHaveLength(1)
expect($('article a[href="/en/github/getting-started-with-github"]')).toHaveLength(1)
})

describe('autogenerated mini TOCs', () => {
Expand Down Expand Up @@ -296,7 +295,7 @@ describe('server', () => {

test('dotcom articles on dotcom have links that include "en"', async () => {
const $ = await getDOM('/en/articles/set-up-git')
expect($(`a[href="/en/articles/managing-files-on-github"]`).length).toBe(1)
expect($('a[href="/en/articles/managing-files-on-github"]').length).toBe(1)
})

test('dotcom articles on dotcom have Enterprise Admin links with latest GHE version', async () => {
Expand All @@ -316,12 +315,12 @@ describe('server', () => {

test('dotcom-only links on GHE are dotcom-only', async () => {
const $ = await getDOM(`${latestEnterprisePath}/github/setting-up-and-managing-your-github-profile/sending-your-github-enterprise-server-contributions-to-your-githubcom-profile`)
expect($(`article a[href="/en/articles/github-privacy-statement"]`).length).toBe(1)
expect($('article a[href="/en/articles/github-privacy-statement"]').length).toBe(1)
})

test('desktop links on GHE are dotcom-only', async () => {
const $ = await getDOM(`${latestEnterprisePath}/github/getting-started-with-github/set-up-git`)
expect($(`article a[href="/en/desktop/installing-and-configuring-github-desktop"]`).length).toBe(1)
expect($('article a[href="/en/desktop/installing-and-configuring-github-desktop"]').length).toBe(1)
})

test('admin articles that link to non-admin articles have Enterprise user links', async () => {
Expand Down Expand Up @@ -405,7 +404,7 @@ describe('server', () => {

test('redirects old articles to their slugified URL', async () => {
const res = await get('/articles/about-github-s-ip-addresses')
expect(res.text).toBe(`Moved Permanently. Redirecting to /en/github/authenticating-to-github/about-githubs-ip-addresses`)
expect(res.text).toBe('Moved Permanently. Redirecting to /en/github/authenticating-to-github/about-githubs-ip-addresses')
})

test('redirects / to /en', async () => {
Expand Down Expand Up @@ -444,13 +443,13 @@ describe('server', () => {
describe('categories and map topics', () => {
test('adds links to categories on the dotcom homepage', async () => {
const $ = await getDOM('/en/github')
expect($(`article a[href="/en/github/managing-large-files"]`).length).toBe(1)
expect($('article a[href="/en/github/managing-large-files"]').length).toBe(1)
expect($('article a[href="#managing-large-files"]').length).toBe(0)
})

test('adds links to map topics on a category homepage', async () => {
const $ = await getDOM('/en/github/setting-up-and-managing-your-github-user-account')
expect($(`article a[href="/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings"]`).length).toBe(1)
expect($('article a[href="/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings"]').length).toBe(1)
expect($('article a[href="#managing-user-account-settings"]').length).toBe(0)
})

Expand All @@ -461,7 +460,7 @@ describe('server', () => {

test('map topic renders with h2 links to articles', async () => {
const $ = await getDOM('/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings')
expect($(`a[href="/en/github/setting-up-and-managing-your-github-user-account/changing-your-github-username"] h2`).length).toBe(1)
expect($('a[href="/en/github/setting-up-and-managing-your-github-user-account/changing-your-github-username"] h2').length).toBe(1)
})

test('map topic renders with one intro for every h2', async () => {
Expand Down Expand Up @@ -572,26 +571,26 @@ describe('GitHub Enterprise URLs', () => {
describe('GitHub Desktop URLs', () => {
test('renders the GitHub Desktop homepage with correct links', async () => {
const $ = await getDOM('/en/desktop')
expect($(`article a[href^="/en/desktop/"]`).length).toBeGreaterThan(1)
expect($('article a[href^="/en/desktop/"]').length).toBeGreaterThan(1)
})

test('renders a Desktop category with expected links', async () => {
const $ = await getDOM('/en/desktop/installing-and-configuring-github-desktop')
expect($(`article a[href^="/en/desktop/installing-and-configuring-github-desktop/"]`).length).toBeGreaterThan(1)
expect($('article a[href^="/en/desktop/installing-and-configuring-github-desktop/"]').length).toBeGreaterThan(1)
})

test('renders a Desktop map topic', async () => {
const $ = await getDOM('/en/desktop/installing-and-configuring-github-desktop/installing-and-authenticating-to-github-desktop')
expect($(`article a[href^="/en/desktop/installing-and-configuring-github-desktop/"]`).length).toBeGreaterThan(1)
expect($('article a[href^="/en/desktop/installing-and-configuring-github-desktop/"]').length).toBeGreaterThan(1)
})

test('renders a Desktop article within a map topic', async () => {
const res = await get(`/en/desktop/installing-and-configuring-github-desktop/installing-github-desktop`)
const res = await get('/en/desktop/installing-and-configuring-github-desktop/installing-github-desktop')
expect(res.statusCode).toBe(200)
})

test('renders the Desktop homepage in Japanese', async () => {
const res = await get(`/ja/desktop`)
const res = await get('/ja/desktop')
expect(res.statusCode).toBe(200)
})
})
Expand Down Expand Up @@ -743,7 +742,7 @@ describe('static routes', () => {
})

describe('index pages', () => {
const nonEnterpriseOnlyPath = `/en/github/getting-started-with-github/verifying-your-email-address`
const nonEnterpriseOnlyPath = '/en/github/getting-started-with-github/verifying-your-email-address'

test('includes dotcom-only links in dotcom TOC', async () => {
const $ = await getDOM('/en/github/getting-started-with-github')
Expand Down
3 changes: 1 addition & 2 deletions tests/rendering/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { getDOM } = require('../helpers/supertest')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')

describe('sidebar', () => {
jest.setTimeout(3 * 60 * 1000)
Expand Down Expand Up @@ -31,7 +30,7 @@ describe('sidebar', () => {
})

test('adds an `is-current-page` class to the sidebar link to the current page', async () => {
const url = `/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings`
const url = '/en/github/setting-up-and-managing-your-github-user-account/managing-user-account-settings'
const $ = await getDOM(url)
expect($('.sidebar .is-current-page').length).toBe(1)
expect($('.sidebar .is-current-page a').attr('href')).toContain(url)
Expand Down
Loading

0 comments on commit 9809627

Please sign in to comment.