Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop' into fix/bridgechain-ux
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarnsley committed Mar 16, 2020
2 parents d6826c6 + e965c09 commit 1340082
Show file tree
Hide file tree
Showing 45 changed files with 618 additions and 288 deletions.
20 changes: 14 additions & 6 deletions __tests__/unit/components/App/AppSidemenu/AppSidemenu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,19 @@ describe('AppSidemenu', () => {
expect(wrapper.vm.isImportantNotificationVisible).toBe(false)
})

it('should toggle & close plugin menu state', () => {
expect(wrapper.vm.isPluginMenuVisible).toBe(false)
wrapper.vm.toggleShowPluginMenu()
expect(wrapper.vm.isPluginMenuVisible).toBe(true)
wrapper.vm.closeShowPlugins()
expect(wrapper.vm.isPluginMenuVisible).toBe(false)
describe('Plugin Menu', () => {
it('should toggle & close plugin menu state', () => {
expect(wrapper.vm.isPluginMenuVisible).toBe(false)
wrapper.vm.toggleShowPluginMenu()
expect(wrapper.vm.isPluginMenuVisible).toBe(true)
wrapper.vm.closeShowPlugins()
expect(wrapper.vm.isPluginMenuVisible).toBe(false)
})

it('should activate the plugin menu item when \'setActive\' is true', () => {
expect(wrapper.vm.activeItem).toBe('mock_route')
wrapper.vm.closeShowPlugins(true)
expect(wrapper.vm.activeItem).toBe('plugin-pages')
})
})
})
36 changes: 26 additions & 10 deletions __tests__/unit/components/Input/InputFee.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@ jest.mock('@/store', () => {
return null
}
}),
'session/lastFeeByType': jest.fn(type => {
switch (type) {
case 0:
return 10000000
case 1:
return undefined
case 3:
return 100000000
default:
return null
'session/lastFeeByType': jest.fn((type, typeGroup) => {
if (typeGroup === 1) {
switch (type) {
case 0:
return 10000000
case 1:
return undefined
case 3:
return 100000000
default:
return null
}
}

return null
})
}
}
Expand Down Expand Up @@ -125,6 +129,18 @@ describe('InputFee', () => {
expect(buttons).toHaveLength(5)
})

it('should set the default chosen fee if available when created', () => {
const wrapper = mountComponent({
mocks: {
session_profile: {
defaultChosenFee: 'LAST'
}
}
})

expect(wrapper.vm.chosenFee).toBe('LAST')
})

describe('maxV1fee', () => {
it('should uses V1 configuration', () => {
let wrapper = mountComponent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,26 @@ const i18n = useI18nGlobally()
let wrapper

const plugins = [
{ id: 'test' }
{
id: 'test 4',
title: 'plugin 4'
},
{
id: 'test 3',
title: 'plugin 3'
},
{
id: 'test 2',
title: 'plugin 2'
},
{
id: 'test 1',
title: 'plugin 1'
},
{
id: 'first test',
title: 'first plugin'
}
]

beforeEach(() => {
Expand Down Expand Up @@ -38,4 +57,17 @@ describe('PluginManagerGrid', () => {
expect(wrapper.emitted('show-details', plugins[0])).toBeTruthy()
})
})

describe('computed', () => {
it('sortedPlugins', () => {
expect(wrapper.vm.sortedPlugins[0].title).toBe('first plugin')
expect(wrapper.vm.sortedPlugins).toEqual([
plugins[4],
plugins[3],
plugins[2],
plugins[1],
plugins[0]
])
})
})
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createLocalVue, mount } from '@vue/test-utils'
import installI18n from '../../../__utils__/i18n'
import CurrencyMixin from '@/mixins/currency'
import TransactionConfirmMultiPayment from '@/components/Transaction/TransactionConfirm/TransactionConfirmMultiPayment'

const localVue = createLocalVue()
Expand Down Expand Up @@ -34,6 +35,7 @@ const createWrapper = (component, transaction) => {
transaction
},
mocks: {
currency_toBuilder: jest.fn(CurrencyMixin.methods.currency_toBuilder),
formatter_networkCurrency: jest.fn((amount) => amount),
wallet_formatAddress: jest.fn((address) => `formatted-${address}`),
wallet_name: jest.fn(wallet => wallet)
Expand Down
103 changes: 0 additions & 103 deletions __tests__/unit/components/utils/Sorting.spec.js

This file was deleted.

118 changes: 74 additions & 44 deletions __tests__/unit/services/plugin-manager/sandbox/storage-sandbox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ beforeAll(() => {
}),
'session/profileId': '1'
},
dispatch: jest.fn((_, data) => {
if (!db[data.profileId]) {
db[data.profileId] = {}
dispatch: jest.fn((action, data) => {
if (action === 'plugin/setPluginOption') {
if (!db[data.profileId]) {
db[data.profileId] = {}
}
db[data.profileId][data.key] = data.value
} else if (action === 'plugin/deletePluginOptionsForProfile') {
delete db[data.profileId]
}
db[data.profileId][data.key] = data.value
})
}
}
Expand Down Expand Up @@ -55,54 +59,80 @@ describe('Storage Sandbox', () => {
expect(walletApi.storage.getOptions).toBeTruthy()
expect(walletApi.storage.get).toBeTruthy()
expect(walletApi.storage.set).toBeTruthy()
expect(walletApi.storage.clear).toBeTruthy()
})

it('should set a value to key', () => {
walletApi.storage.set(localOptions.key, localOptions.value)
expect(app.$store.dispatch).toHaveBeenCalledWith('plugin/setPluginOption', localOptions)
})

it('should set a value to global key', () => {
walletApi.storage.set(globalOptions.key, globalOptions.value, true)
expect(app.$store.dispatch).toHaveBeenCalledWith('plugin/setPluginOption', globalOptions)
})

it('should get the value of key', () => {
const result = walletApi.storage.get(localOptions.key)
expect(app.$store.getters['plugin/pluginOptions']).toHaveBeenCalledWith(plugin.config.id, '1')
expect(result).toBe(localOptions.value)
})

it('should get the value of global key from the same profile', () => {
const result = walletApi.storage.get(globalOptions.key, true)
expect(result).toBe(globalOptions.value)
})
describe('set', () => {
it('should set a value to key', () => {
walletApi.storage.set(localOptions.key, localOptions.value)
expect(app.$store.dispatch).toHaveBeenCalledWith('plugin/setPluginOption', localOptions)
})

it('should get the value of global key from a different profile', () => {
app.$store.getters['session/profileId'] = '2'
const result = walletApi.storage.get(globalOptions.key, true)
expect(result).toBe(globalOptions.value)
it('should set a value to global key', () => {
walletApi.storage.set(globalOptions.key, globalOptions.value, true)
expect(app.$store.dispatch).toHaveBeenCalledWith('plugin/setPluginOption', globalOptions)
})
})

it('should NOT get the value of a local key from a different profile', () => {
app.$store.getters['session/profileId'] = '2'
const result = walletApi.storage.get(localOptions.key)
expect(result).toBe(undefined)
describe('get', () => {
it('should get the value of key', () => {
const result = walletApi.storage.get(localOptions.key)
expect(app.$store.getters['plugin/pluginOptions']).toHaveBeenCalledWith(plugin.config.id, '1')
expect(result).toBe(localOptions.value)
})

it('should get the value of global key from the same profile', () => {
const result = walletApi.storage.get(globalOptions.key, true)
expect(result).toBe(globalOptions.value)
})

it('should get the value of global key from a different profile', () => {
app.$store.getters['session/profileId'] = '2'
const result = walletApi.storage.get(globalOptions.key, true)
expect(result).toBe(globalOptions.value)
})

it('should NOT get the value of a local key from a different profile', () => {
app.$store.getters['session/profileId'] = '2'
const result = walletApi.storage.get(localOptions.key)
expect(result).toBe(undefined)
})
})

it('should get all local values', () => {
app.$store.getters['session/profileId'] = '1'
let result = walletApi.storage.getOptions()
expect(Object.keys(result)).toHaveLength(1)
expect(result).toHaveProperty(localOptions.key, localOptions.value)
app.$store.getters['session/profileId'] = '2'
result = walletApi.storage.getOptions()
expect(Object.keys(result)).toHaveLength(0)
describe('getOptions', () => {
it('should get all local values', () => {
app.$store.getters['session/profileId'] = '1'
let result = walletApi.storage.getOptions()
expect(Object.keys(result)).toHaveLength(1)
expect(result).toHaveProperty(localOptions.key, localOptions.value)
app.$store.getters['session/profileId'] = '2'
result = walletApi.storage.getOptions()
expect(Object.keys(result)).toHaveLength(0)
})

it('should get all global values', () => {
const result = walletApi.storage.getOptions(true)
expect(Object.keys(result)).toHaveLength(1)
expect(result).toHaveProperty(globalOptions.key, globalOptions.value)
})
})

it('should get all global values', () => {
const result = walletApi.storage.getOptions(true)
expect(Object.keys(result)).toHaveLength(1)
expect(result).toHaveProperty(globalOptions.key, globalOptions.value)
describe('clear', () => {
beforeAll(() => {
walletApi.storage.set(localOptions.key, localOptions.value)
walletApi.storage.set(globalOptions.key, globalOptions.value, true)
})

it('should clear all local values', () => {
expect(walletApi.storage.get(localOptions.key)).toBe(localOptions.value)
walletApi.storage.clear()
expect(walletApi.storage.get(localOptions.key)).toBe(undefined)
})

it('should clear all global values', () => {
expect(walletApi.storage.get(globalOptions.key, true)).toBe(globalOptions.value)
walletApi.storage.clear(true)
expect(walletApi.storage.get(globalOptions.key, true)).toBe(undefined)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const plugin = new Plugin({

plugin.routes = [
{
name: 'test'
name: '1:test'
}
]

Expand Down

0 comments on commit 1340082

Please sign in to comment.