This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: plugin manager unit tests (#1583)
* refactor: properly mount PluginInstallModal in tests * refactor: properly mount PluginManagerTable in tests * refactor: pass labels to switch button component * test: initial tests for plugin store module * test: more unit tests * refactor: restart store unit tests * tests: more unit tests * tests: restructure and add tests * tests: add tests for enabled getter * tests: add tests for isBlacklisted getter * tests: add tests for isWhitelisted getter * tests: add tests for isUpdateAvailable getter * tests: add tests for latestVersion getter * refactor: return boolean values from isEnabled getter * tests: add tests for isEnabled getter * tests: add tests for isInstalledSupported getter * tests: add tests for isLoaded getter * refactor: return boolean values from profileHasPluginOptions getter * tests: add tests for profileHasPluginOptions getter * tests: add tests for pluginOptions getter * style: fix strange whitespace * chore: remove blacklist fix for tainted profiles * tests: add tests for reset action * tests: add tests for loadPluginsForProfiles action * refactor: use dispatch in isWhitelisted test * style: missing space * tests: add tests for loadPluginsForProfile action * tests: add tests for setBlacklisted action * refactor: mock release service * refactor: remove releaseService mock, spy on getter instead * refactor: group getters in describe block * refactor: simplify store setups * tests: add tests for filtered getter * tests: add tests for setLoaded action * tests: add tests for setEnabled action * style: resolve style guide violations * refactor: change setLoaded test to cover all branches * refactor: setup state only once in setEnabled tests * tests: add tests for deletePlugin action * tests: add tests for avatar getter * refactor: change assignment of loadedPlugins in avatars getters * tests: add tests for menuItems getter * tests: add tests for setMenuItems action * tests: cover missing branch in setMenuItems action * tests: add tests for themes getter * tests: add tests for setThemes action * tests: add tests for deleteLoaded action * tests: add tests for deletePluginOptionsForProfile action * tests: add tests for deleteInstalled action * tests: add tests for setAvatars action * tests: add tests for setPluginOption action * tests: add tests for avatars getter * tests: add tests for missing branch of deletePluginOptionsForProfile actions * tests: add tests for walletTabs getter * tests: add tests for setWalletTabs action Co-authored-by: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com>
- Loading branch information
1 parent
4a1a424
commit b2832b2
Showing
9 changed files
with
1,913 additions
and
68 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
5 changes: 4 additions & 1 deletion
5
...ts__/unit/components/PluginManager/PluginManagerButtons/PluginManagerButtonSwitch.spec.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
91 changes: 85 additions & 6 deletions
91
__tests__/unit/components/PluginManager/PluginManagerModals/PluginInstallModal.spec.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 |
---|---|---|
@@ -1,28 +1,107 @@ | ||
import { shallowMount } from '@vue/test-utils' | ||
import { mount } from '@vue/test-utils' | ||
import useI18nGlobally from '../../../__utils__/i18n' | ||
import { PluginInstallModal } from '@/components/PluginManager/PluginManagerModals' | ||
|
||
jest.mock('electron', () => ({ | ||
ipcRenderer: { | ||
on: jest.fn() | ||
on: jest.fn(), | ||
send: jest.fn(), | ||
removeListener: jest.fn() | ||
} | ||
})) | ||
|
||
const i18n = useI18nGlobally() | ||
let wrapper | ||
|
||
const plugin = { | ||
id: 'test', | ||
source: 'source' | ||
} | ||
|
||
const availablePlugin = { | ||
config: { | ||
id: 'test', | ||
source: 'store-source' | ||
} | ||
} | ||
|
||
const mocks = { | ||
$store: { | ||
getters: { | ||
'plugin/availableById': jest.fn(() => availablePlugin) | ||
} | ||
}, | ||
formatter_bytes: jest.fn(bytes => bytes), | ||
formatter_percentage: jest.fn() | ||
} | ||
|
||
beforeEach(() => { | ||
wrapper = shallowMount(PluginInstallModal, { | ||
wrapper = mount(PluginInstallModal, { | ||
i18n, | ||
mocks, | ||
propsData: { | ||
plugin: { | ||
id: 'test' | ||
} | ||
plugin | ||
}, | ||
stubs: { | ||
Portal: '<div><slot /></div>' | ||
} | ||
}) | ||
|
||
wrapper.setData({ | ||
progress: { | ||
percent: 0.5, | ||
transferredBytes: 50, | ||
totalBytes: 100 | ||
} | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
wrapper.destroy() | ||
}) | ||
|
||
describe('PluginInstallModal', () => { | ||
it('should render', () => { | ||
expect(wrapper.isVueInstance()).toBeTrue() | ||
}) | ||
|
||
describe('Methods', () => { | ||
it('should emit install event', () => { | ||
wrapper.vm.emitInstall() | ||
expect(wrapper.emitted('install')).toBeTruthy() | ||
}) | ||
|
||
describe('emitDownload', () => { | ||
it('should emit download event with plugin source', () => { | ||
wrapper.vm.emitDownload() | ||
expect(wrapper.emitted('download', plugin.source)).toBeTruthy() | ||
}) | ||
|
||
it('should emit download event with available plugin source if update', () => { | ||
wrapper.setProps({ isUpdate: true }) | ||
wrapper.vm.emitDownload() | ||
expect(wrapper.emitted('download', availablePlugin.config.source)).toBeTruthy() | ||
}) | ||
}) | ||
|
||
describe('emitClose', () => { | ||
it('should emit close event', () => { | ||
wrapper.vm.emitClose() | ||
expect(wrapper.emitted('close')).toBeTruthy() | ||
}) | ||
|
||
it('should call cancel()', () => { | ||
jest.spyOn(wrapper.vm, 'cancel') | ||
wrapper.vm.emitClose() | ||
expect(wrapper.vm.cancel).toHaveBeenCalled() | ||
}) | ||
|
||
it('should call cleanup() if download failed', () => { | ||
wrapper.setData({ isDownloadFailed: true }) | ||
jest.spyOn(wrapper.vm, 'cleanup') | ||
wrapper.vm.emitClose() | ||
expect(wrapper.vm.cleanup).toHaveBeenCalled() | ||
}) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,11 +1,18 @@ | ||
import release from '@/services/release' | ||
import releaseService from '@/services/release' | ||
import packageJson from '@package.json' | ||
|
||
const releaseUrl = 'https://github.com/ArkEcosystem/desktop-wallet/releases/latest' | ||
|
||
describe('Services > Release', () => { | ||
describe('currentVersion', () => { | ||
it('should return the current version', () => { | ||
expect(releaseService.currentVersion).toEqual(packageJson.version) | ||
}) | ||
}) | ||
|
||
describe('latestReleaseUrl', () => { | ||
it('returns the URL of the latest release endpoint', () => { | ||
expect(release.latestReleaseUrl).toEqual(releaseUrl) | ||
it('should return the URL of the latest release endpoint', () => { | ||
expect(releaseService.latestReleaseUrl).toEqual(releaseUrl) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.