Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tripodsan committed Aug 15, 2023
1 parent 49e8102 commit 4e44c4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/GoogleClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ export class GoogleClient {
throw new StatusCodeError(`Not Found: ${fileId}`, 404);
}
// convert message to string
/* c8 ignore next 3 */
if (e.message instanceof ArrayBuffer) {
e.message = Buffer.from(e.message).toString('utf-8');
}
Expand Down
15 changes: 10 additions & 5 deletions test/google-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ describe('GoogleClient tests', () => {
nock.loginGoogle(1);
nock('https://www.googleapis.com')
.get('/drive/v3/files/1bH7_28a1-Q3QEEvFhT9eTmR-D7_9F4xP?alt=media&supportsAllDrives=true')
.reply(404);
.reply(404, {});

const client = await new GoogleClient({
log: console,
Expand Down Expand Up @@ -901,7 +901,7 @@ describe('GoogleClient tests', () => {

nock('https://www.googleapis.com')
.get('/drive/v3/files/oldid?alt=media&supportsAllDrives=true')
.reply(404)
.reply(404, {})
.get('/drive/v3/files/newid?alt=media&supportsAllDrives=true')
.reply(200, 'hello');

Expand Down Expand Up @@ -937,7 +937,7 @@ describe('GoogleClient tests', () => {
nock('https://www.googleapis.com')
.get('/drive/v3/files/oldid?alt=media&supportsAllDrives=true')
.twice()
.reply(404);
.reply(404, {});

const client = await new GoogleClient({
log: console,
Expand Down Expand Up @@ -967,7 +967,12 @@ describe('GoogleClient tests', () => {

nock('https://www.googleapis.com')
.get('/drive/v3/files/oldid?alt=media&supportsAllDrives=true')
.reply(401);
.reply(403, {
error: {
code: 403,
message: 'The request is missing a valid API key.',
},
});

const client = await new GoogleClient({
log: console,
Expand All @@ -976,7 +981,7 @@ describe('GoogleClient tests', () => {
cachePlugin,
}).init();

await assert.rejects(client.getFileFromPath('1', '/document1'), new Error(''));
await assert.rejects(client.getFileFromPath('1', '/document1'), new Error('The request is missing a valid API key.'));
});
});

Expand Down

0 comments on commit 4e44c4d

Please sign in to comment.