From deb6be93f0a27248582041ca35fccedf9a2a11a2 Mon Sep 17 00:00:00 2001 From: Pierre Huyghe Date: Wed, 7 Sep 2022 10:19:41 +0200 Subject: [PATCH] refactor: add tbody to contributors table (#307) * refactor: add tbody to contributors table * chore(node): bump version to lts * fix(html): add correct indentation * test(url): fix bind error message Co-authored-by: Pierre Huyghe --- .circleci/config.yml | 2 +- .nvmrc | 2 +- .../__tests__/__snapshots__/index.js.snap | 36 ++++++++------- src/generate/index.js | 10 ++-- src/util/__tests__/url.js | 46 +++++++++++-------- 5 files changed, 54 insertions(+), 42 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 009ab1e..ceb88c7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 docker_defaults: &docker_defaults docker: - - image: circleci/node:12.14.0 + - image: cimg/node:16.17.0 commands: prep_env: diff --git a/.nvmrc b/.nvmrc index 65d83ce..2a4e4ab 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -12.14.0 +16.17.0 diff --git a/src/generate/__tests__/__snapshots__/index.js.snap b/src/generate/__tests__/__snapshots__/index.js.snap index 52a0eeb..cb402f9 100644 --- a/src/generate/__tests__/__snapshots__/index.js.snap +++ b/src/generate/__tests__/__snapshots__/index.js.snap @@ -11,11 +11,13 @@ These people contributed to the project: - - - - - + + + + + + +
Kent C. Dodds is awesome!Divjot Singh is awesome!Jeroen Engels is awesome!
Kent C. Dodds is awesome!Divjot Singh is awesome!Jeroen Engels is awesome!
@@ -37,17 +39,19 @@ These people contributed to the project: - - - - - - - - - - - + + + + + + + + + + + + +
Kent C. Dodds is awesome!Kent C. Dodds is awesome!Kent C. Dodds is awesome!Kent C. Dodds is awesome!Kent C. Dodds is awesome!
Kent C. Dodds is awesome!Kent C. Dodds is awesome!
Kent C. Dodds is awesome!Kent C. Dodds is awesome!Kent C. Dodds is awesome!Kent C. Dodds is awesome!Kent C. Dodds is awesome!
Kent C. Dodds is awesome!Kent C. Dodds is awesome!
diff --git a/src/generate/index.js b/src/generate/index.js index cacc21e..b9b7e21 100644 --- a/src/generate/index.js +++ b/src/generate/index.js @@ -3,7 +3,7 @@ const formatBadge = require('./format-badge') const formatContributor = require('./format-contributor') function injectListBetweenTags(newContent) { - return function(previousContent) { + return function (previousContent) { const tagToLookFor = `' const startOfOpeningTagIndex = previousContent.indexOf( @@ -39,7 +39,7 @@ function injectListBetweenTags(newContent) { function formatLine(contributors) { return `${contributors.join( - '\n ', + '\n ', )}` } @@ -55,15 +55,15 @@ function generateContributorsList(options, contributors) { }), _.chunk(options.contributorsPerLine), _.map(formatLine), - _.join('\n \n \n '), + _.join('\n \n \n '), newContent => { - return `\n\n \n ${newContent}\n \n
\n\n` + return `\n\n \n \n ${newContent}\n \n \n
\n\n` }, )(contributors) } function replaceBadge(newContent) { - return function(previousContent) { + return function (previousContent) { const tagToLookFor = `' const startOfOpeningTagIndex = previousContent.indexOf( diff --git a/src/util/__tests__/url.js b/src/util/__tests__/url.js index 50ff6d4..359775e 100644 --- a/src/util/__tests__/url.js +++ b/src/util/__tests__/url.js @@ -1,49 +1,57 @@ -import url from '../url'; +import url from '../url' test(`Result of protocol validation should be true`, () => { - expect(url.isHttpProtocol('http:')).toBe(true) - expect(url.isHttpProtocol('https:')).toBe(true) + expect(url.isHttpProtocol('http:')).toBe(true) + expect(url.isHttpProtocol('https:')).toBe(true) }) test(`Result of protocol validation should be false`, () => { - expect(url.isHttpProtocol('ftp:')).toBe(false) + expect(url.isHttpProtocol('ftp:')).toBe(false) }) test(`Result of url validation should be true`, () => { - expect(url.isValidHttpUrl('https://api.github.com/users/octocat')).toBe(true) + expect(url.isValidHttpUrl('https://api.github.com/users/octocat')).toBe(true) }) test(`Result of url validation should be false when url uses wrong protocol`, () => { - expect(url.isValidHttpUrl('git://git@github.com:all-contributors/all-contributors-cli.git')).toBe(false) + expect( + url.isValidHttpUrl( + 'git://git@github.com:all-contributors/all-contributors-cli.git', + ), + ).toBe(false) }) test(`Result of url validation should be false when input isn't url`, () => { - expect(url.isValidHttpUrl('github-octocat')).toBe(false) + expect(url.isValidHttpUrl('github-octocat')).toBe(false) }) test(`Result of parsed url should be equal`, () => { - const input = 'https://api.github.com/users/octocat' - const expected = 'https://api.github.com/users/octocat' - expect(url.parseHttpUrl(input)).toBe(expected) + const input = 'https://api.github.com/users/octocat' + const expected = 'https://api.github.com/users/octocat' + expect(url.parseHttpUrl(input)).toBe(expected) }) test(`Result of parsed url without protocol should be equal`, () => { - const input = 'example.com' - const expected = 'http://example.com/' - expect(url.parseHttpUrl(input)).toBe(expected) + const input = 'example.com' + const expected = 'http://example.com/' + expect(url.parseHttpUrl(input)).toBe(expected) }) test(`Throw an error when parsed input isn't a string`, () => { - const input = 123 - expect(url.parseHttpUrl.bind(null, input)).toThrowError('input must be a string') + const input = 123 + expect(url.parseHttpUrl.bind(null, input)).toThrowError( + 'input must be a string', + ) }) test(`Throw an error when parsed url has wrong protocol`, () => { - const input = 'ftp://domain.xyz' - expect(url.parseHttpUrl.bind(null, input)).toThrowError('Provided URL has an invalid protocol') + const input = 'ftp://domain.xyz' + expect(url.parseHttpUrl.bind(null, input)).toThrowError( + 'Provided URL has an invalid protocol', + ) }) test(`Throw an error when parsed input isn't a URL`, () => { - const input = 'some string' - expect(url.parseHttpUrl.bind(null, input)).toThrowError('Invalid URL: http://some string') + const input = 'some string' + expect(url.parseHttpUrl.bind(null, input)).toThrowError('Invalid URL') })