Skip to content

Commit

Permalink
feat: add an icon for Electron DLs being unzipped (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckerr authored Mar 27, 2021
1 parent 362798d commit daabf45
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
15 changes: 10 additions & 5 deletions src/renderer/components/version-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ export function getItemLabel({ source, state, name }: RunnableVersion): string {
* @returns
*/
export function getItemIcon({ state }: RunnableVersion) {
return state === 'ready'
? 'saved'
: state === 'downloading'
? 'cloud-download'
: 'cloud';
switch (state) {
case VersionState.unknown:
return 'cloud';
case VersionState.ready:
return 'saved';
case VersionState.downloading:
return 'cloud-download';
case VersionState.unzipping:
return 'compressed';
}
}

/**
Expand Down
19 changes: 10 additions & 9 deletions tests/renderer/components/version-select-spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { ElectronReleaseChannel } from '../../../src/renderer/versions';
import { mockVersions } from '../../mocks/electron-versions';

const { ready, unknown, downloading } = VersionState;
const { downloading, ready, unknown, unzipping } = VersionState;
const { remote, local } = VersionSource;

describe('VersionSelect component', () => {
Expand Down Expand Up @@ -133,14 +133,15 @@ describe('VersionSelect component', () => {

describe('getItemIcon()', () => {
it('returns the correct icon', () => {
const vDownloaded = { ...mockVersion1, state: ready };
expect(getItemIcon(vDownloaded)).toBe('saved');

const vDownloading = { ...mockVersion1, state: downloading };
expect(getItemIcon(vDownloading)).toBe('cloud-download');

const vUnknown = { ...mockVersion1, state: unknown };
expect(getItemIcon(vUnknown)).toBe('cloud');
const icons: Array<{ state: VersionState; expected: string }> = [
{ state: downloading, expected: 'cloud-download' },
{ state: ready, expected: 'saved' },
{ state: unknown, expected: 'cloud' },
{ state: unzipping, expected: 'compressed' },
];
icons.forEach(({ state, expected }) => {
expect(getItemIcon({ ...mockVersion1, state })).toBe(expected);
});
});
});

Expand Down

0 comments on commit daabf45

Please sign in to comment.