build(docs-infra): upgrade all JS dependencies to latest versions (#36837)

This commit upgrades all dependencies in `scripts-js/` to latest
versions and also includes all necessary code changes to ensure the
tests are passing with the new dependency versions.

PR Close #36837
This commit is contained in:
George Kalpakas
2020-05-02 16:14:05 +03:00
committed by Alex Rickabaugh
parent 333abf16e4
commit eef01160f4
12 changed files with 1054 additions and 1649 deletions

View File

@ -217,7 +217,7 @@ describe('GithubApi', () => {
describe('request()', () => {
it('should return a promise', () => {
nock('https://api.github.com').get('').reply(200);
nock('https://api.github.com').get('/').reply(200);
expect((api as any).request()).toEqual(jasmine.any(Promise));
});

View File

@ -1,6 +1,6 @@
// Imports
import {GithubApi} from '../../lib/common/github-api';
import {GithubPullRequests} from '../../lib/common/github-pull-requests';
import {GithubPullRequests, PullRequest} from '../../lib/common/github-pull-requests';
// Tests
describe('GithubPullRequests', () => {
@ -47,7 +47,7 @@ describe('GithubPullRequests', () => {
it('should make a POST request to Github with the correct pathname, params and data', () => {
githubApi.post.and.callFake(() => Promise.resolve());
githubApi.post.and.resolveTo();
prs.addComment(42, 'body');
expect(githubApi.post).toHaveBeenCalledWith('/repos/foo/bar/issues/42/comments', null, {body: 'body'});
});
@ -63,7 +63,7 @@ describe('GithubPullRequests', () => {
it('should resolve with the data from the Github POST', done => {
githubApi.post.and.callFake(() => Promise.resolve('Test'));
githubApi.post.and.resolveTo('Test');
prs.addComment(42, 'body').then(data => {
expect(data).toBe('Test');
done();
@ -125,9 +125,14 @@ describe('GithubPullRequests', () => {
});
it('should forward the value returned by \'getPaginated()\'', () => {
githubApi.getPaginated.and.returnValue('Test');
expect(prs.fetchAll() as any).toBe('Test');
it('should forward the value returned by \'getPaginated()\'', async () => {
const mockPrs: PullRequest[] = [
{number: 1, user: {login: 'foo'}, labels: []},
{number: 2, user: {login: 'bar'}, labels: []},
];
githubApi.getPaginated.and.resolveTo(mockPrs);
expect(await prs.fetchAll()).toBe(mockPrs);
});
});

View File

@ -1,5 +1,5 @@
import {GithubApi} from '../../lib/common/github-api';
import {GithubTeams} from '../../lib/common/github-teams';
import {GithubTeams, Team} from '../../lib/common/github-teams';
// Tests
describe('GithubTeams', () => {
@ -33,9 +33,14 @@ describe('GithubTeams', () => {
});
it('should forward the value returned by \'getPaginated()\'', () => {
githubApi.getPaginated.and.returnValue('Test');
expect(teams.fetchAll() as any).toBe('Test');
it('should forward the value returned by \'getPaginated()\'', async () => {
const mockTeams: Team[] = [
{id: 1, slug: 'foo'},
{id: 2, slug: 'bar'},
];
githubApi.getPaginated.and.resolveTo(mockTeams);
expect(await teams.fetchAll()).toBe(mockTeams);
});
});
@ -50,7 +55,7 @@ describe('GithubTeams', () => {
it('should return a promise', () => {
githubApi.get.and.callFake(() => Promise.resolve());
githubApi.get.and.resolveTo();
const promise = teams.isMemberById('user', [1]);
expect(promise).toEqual(jasmine.any(Promise));
});
@ -66,7 +71,7 @@ describe('GithubTeams', () => {
it('should call \'get()\' with the correct pathname', done => {
githubApi.get.and.callFake(() => Promise.resolve());
githubApi.get.and.resolveTo();
teams.isMemberById('user', [1]).then(() => {
expect(githubApi.get).toHaveBeenCalledWith('/teams/1/memberships/user');
done();
@ -85,7 +90,7 @@ describe('GithubTeams', () => {
it('should resolve with false if the membership is not active', done => {
githubApi.get.and.callFake(() => Promise.resolve({state: 'pending'}));
githubApi.get.and.resolveTo({state: 'pending'});
teams.isMemberById('user', [1]).then(isMember => {
expect(isMember).toBe(false);
expect(githubApi.get).toHaveBeenCalled();
@ -95,7 +100,7 @@ describe('GithubTeams', () => {
it('should resolve with true if the membership is active', done => {
githubApi.get.and.callFake(() => Promise.resolve({state: 'active'}));
githubApi.get.and.resolveTo({state: 'active'});
teams.isMemberById('user', [1]).then(isMember => {
expect(isMember).toBe(true);
done();
@ -104,7 +109,7 @@ describe('GithubTeams', () => {
it('should sequentially call \'get()\' until an active membership is found', done => {
const trainedResponses: {[pathname: string]: Promise<{state: string}>} = {
const trainedResponses: {[pathname: string]: Promise<any>} = {
'/teams/1/memberships/user': Promise.resolve({state: 'pending'}),
'/teams/2/memberships/user': Promise.reject(null),
'/teams/3/memberships/user': Promise.resolve({state: 'active'}),
@ -125,7 +130,7 @@ describe('GithubTeams', () => {
it('should resolve with false if no active membership is found', done => {
const trainedResponses: {[pathname: string]: Promise<{state: string}>} = {
const trainedResponses: {[pathname: string]: Promise<any>} = {
'/teams/1/memberships/user': Promise.resolve({state: 'pending'}),
'/teams/2/memberships/user': Promise.reject(null),
'/teams/3/memberships/user': Promise.resolve({state: 'not active'}),