-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into pixie-ga-2
- Loading branch information
Showing
497 changed files
with
7,381 additions
and
9,600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ module.exports = { | |
tabWidth: 2, | ||
semi: true, | ||
singleQuote: true, | ||
arrowParens: 'always', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
scripts/actions/__tests__/send-and-update-translation-queue.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const fs = require('fs'); | ||
|
||
const { getContent } = require('../send-and-update-translation-queue'); | ||
|
||
jest.mock('../serialize-mdx'); | ||
jest.mock('fs'); | ||
|
||
test('getContent skips over files that dont exist', async () => { | ||
fs.existsSync | ||
.mockReturnValueOnce(false) | ||
.mockReturnValueOnce(false) | ||
.mockReturnValueOnce(false) | ||
.mockReturnValue(true); | ||
|
||
const mockInput = { | ||
jp: ['slug1', 'slug2', 'slug3', 'slug4', 'slug5'], | ||
}; | ||
|
||
const fileContent = getContent(mockInput); | ||
const pages = await fileContent['jp']; | ||
|
||
expect(pages.length).toBe(2); // 5 submitted slugs - 3 false mock returns = 2 files not skipped | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
scripts/actions/utils/__tests__/github-api-helpers.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
'use strict'; | ||
|
||
const { | ||
getNextLink, | ||
fetchPaginatedGHResults, | ||
} = require('../github-api-helpers'); | ||
|
||
jest.mock('node-fetch'); | ||
|
||
const fetch = require('node-fetch'); | ||
|
||
describe('Github API Helpers', () => { | ||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
describe('getNextLink', () => { | ||
test('returns null for malformed header', () => { | ||
expect(getNextLink('askdflaksjdhf2421dfdfs')).toBe(null); | ||
}); | ||
|
||
test('returns null when `next` is not present', () => { | ||
expect( | ||
getNextLink('<https://fakesite.com/files?page=1>; rel="last"') | ||
).toBe(null); | ||
}); | ||
|
||
test('returns url for next page', () => { | ||
expect( | ||
getNextLink( | ||
'<https://fakesite.com/files?page=36>; rel="last", <https://fakesite.com/files?page=2>; rel="next"' | ||
) | ||
).toEqual('https://fakesite.com/files?page=2'); | ||
}); | ||
}); | ||
|
||
describe('fetchPaginatedGHResults', () => { | ||
test('throws error when response is not ok', async () => { | ||
fetch.mockResolvedValueOnce({ ok: false }); | ||
await expect(fetchPaginatedGHResults('test', 'test')).rejects.toThrow(); | ||
}); | ||
|
||
test('properly sets API URL and token', async () => { | ||
fetch.mockResolvedValueOnce({ | ||
ok: true, | ||
json: () => Promise.resolve([]), | ||
headers: { | ||
get: () => null, | ||
}, | ||
}); | ||
|
||
await fetchPaginatedGHResults('testurl', 'testtoken'); | ||
expect(fetch.mock.calls[0]).toEqual([ | ||
'testurl', | ||
{ headers: { authorization: 'token testtoken' } }, | ||
]); | ||
}); | ||
|
||
test('returns 1 page of results', async () => { | ||
const files = [{ file: 1 }, { file: 2 }, { file: 3 }]; | ||
fetch.mockResolvedValueOnce({ | ||
ok: true, | ||
json: () => Promise.resolve(files), | ||
headers: { | ||
get: () => null, | ||
}, | ||
}); | ||
|
||
const page = await fetchPaginatedGHResults('test', 'test'); | ||
expect(page).toEqual(files); | ||
}); | ||
|
||
test('returns more than 1 page of results', async () => { | ||
const files = [{ file: 1 }, { file: 2 }, { file: 3 }]; | ||
fetch | ||
.mockResolvedValueOnce({ | ||
ok: true, | ||
json: () => Promise.resolve(files.slice(0, 1)), | ||
headers: { | ||
get: () => '<https://fakesite.com/files?page=2>; rel="next"', | ||
}, | ||
}) | ||
.mockResolvedValueOnce({ | ||
ok: true, | ||
json: () => Promise.resolve(files.slice(1, 2)), | ||
headers: { | ||
get: () => '<https://fakesite.com/files?page=3>; rel="next"', | ||
}, | ||
}) | ||
.mockResolvedValueOnce({ | ||
ok: true, | ||
json: () => Promise.resolve(files.slice(2)), | ||
headers: { | ||
get: () => '', | ||
}, | ||
}); | ||
|
||
const pages = await fetchPaginatedGHResults('test', 'test'); | ||
expect(pages).toEqual(files); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.