Skip to content

Commit

Permalink
fix: public and private gist labels match reality
Browse files Browse the repository at this point in the history
fixes #96
  • Loading branch information
Ken Howard committed Feb 3, 2019
1 parent 6e6e163 commit 9b74fea
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions __mocks__/@octokit/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const gistsResponseData = [
type: 'text'
}
},
html_url: 'https://foo.bar',
id: 'test123',
public: true,
updated_at: new Date().toString()
},
{
Expand All @@ -47,7 +49,9 @@ const gistsResponseData = [
type: 'text'
}
},
html_url: 'https://foo.bar',
id: 'test123',
public: false,
updated_at: new Date().toString()
}
];
Expand Down
18 changes: 18 additions & 0 deletions src/gists/__tests__/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ describe('Gists API Tests', () => {

expect(gists[0].description).toBe('gist one');
});
test('public gists should remain public', async () => {
expect.assertions(2);

const gists: any = await getGists();

expect(gists[1].public).toBe(false);
expect(gists[0]).toStrictEqual({
createdAt: expect.any(String),
description: 'gist one',
fileCount: expect.any(Number),
files: expect.any(Object),
id: expect.any(String),
name: 'gist one',
public: true,
updatedAt: expect.any(String),
url: expect.any(String)
});
});
});
describe('#getGist', () => {
test('retrieves a gist by id', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/gists/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const formatGist = (gist: GistResponse): Gist => ({
files: gist.files,
id: gist.id,
name: gist.description || Object.keys(gist.files)[0],
public: !gist.public,
public: gist.public,
updatedAt: new Intl.DateTimeFormat(env.language, {
day: 'numeric',
month: 'long',
Expand Down

0 comments on commit 9b74fea

Please sign in to comment.