Skip to content

Commit

Permalink
refactor: delete unused code and fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Feb 8, 2024
1 parent 5d60b40 commit 885c14b
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ afterEach(() => {

describe('overwriteConfigFile', () => {
test('Should overwrite the configuration with a single url according to the parameters given', () => {
vi.spyOn(fs, 'writeFileSync').mockImplementation
vi.spyOn(fs, 'writeFileSync')
vi.spyOn(fs, 'readFileSync').mockImplementation(
() => 'node_url = "public_node_url3"',
)
Expand All @@ -31,7 +31,7 @@ describe('overwriteConfigFile', () => {
})

test('Should overwrite the configuration with several nodes according to the parameters given', () => {
vi.spyOn(fs, 'writeFileSync').mockImplementation
vi.spyOn(fs, 'writeFileSync')
vi.spyOn(fs, 'readFileSync').mockImplementation(
() => 'node_url = "public_node_url3","public_node_url4"',
)
Expand All @@ -53,7 +53,7 @@ describe('overwriteConfigFile', () => {
})

test("Should handle error if read file doesn't exists", () => {
vi.spyOn(fs, 'writeFileSync').mockImplementation
vi.spyOn(fs, 'writeFileSync')
vi.spyOn(fs, 'readFileSync').mockImplementation

overwriteWitnetNodeConfiguration({
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/src/components/AddressCardButton.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('AddressCardButton.vue', () => {
)
const btn = wrapper.find('[data-test="address-card-button"]')
await btn.trigger('click')
expect(wrapper.emitted().click).toBeTruthy
expect(wrapper.emitted().click).toBeTruthy()
})
})
})
1 change: 0 additions & 1 deletion tests/unit/src/components/Balance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import BalanceData from '@/components/BalanceData.vue'
import BalanceButtons from '@/components/BalanceButtons.vue'
import SendValueTransfer from '@/components/SendTransaction/SendValueTransfer.vue'

import { describe, expect, test, vi } from 'vitest'
import { WIT_UNIT, DEFAULT_VTT_VALUES } from '@/constants'

describe('Balance.vue', () => {
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/src/components/BalanceButtons.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import BalanceButtons from '@/components/BalanceButtons.vue'
import { NETWORK_STATUS } from '@/constants'
import { describe, expect, test, vi } from 'vitest'

describe('BalanceButtons.vue', () => {
describe('should render receive and send buttons', () => {
Expand Down Expand Up @@ -69,8 +68,6 @@ describe('BalanceButtons.vue', () => {
await tryButton.trigger('click')
await flushPromises()

console.log(wrapper.emitted())

expect(wrapper.emitted()['send']).toBeTruthy()
})

Expand Down
7 changes: 4 additions & 3 deletions tests/unit/src/components/CreateDataRequestForm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('CreateDataRequestForm.vue', () => {
'el-form': ElForm,
'el-form-item': ElFormItem,
AppendUnit: true,
teleport: true,
},
})
describe('should render properly the form items', () => {
Expand Down Expand Up @@ -121,7 +122,7 @@ describe('CreateDataRequestForm.vue', () => {
await flushPromises()
expect(wrapper.emitted()['set-dr-values']).toBeTruthy()
})

// TODO: Skip until being able to access to element plus input error
test.skip('should show an error if the input cannot be converted to number', async () => {
const wrapper = mount(CreateDataRequestForm, {
props: {
Expand All @@ -136,13 +137,12 @@ describe('CreateDataRequestForm.vue', () => {
await submitBtn.trigger('click')
await flushPromises()
await flushPromises()
const error = wrapper.find('.el-form-item__error')
console.log(error)
expect(wrapper.find('.el-form-item__error').text()).toBe(
`This should be a number`,
)
})

// TODO: Skip until being able to access to element plus input error
test.skip('should show an error if the input is less than 1 nanoWit', async () => {
const wrapper = mount(CreateDataRequestForm, {
props: {
Expand All @@ -161,6 +161,7 @@ describe('CreateDataRequestForm.vue', () => {
)
})

// TODO: Skip until being able to access to element plus input error
test.skip('should show an error if the collateral is less than 1 wit', async () => {
const wrapper = mount(CreateDataRequestForm, {
props: {
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/components/EditorStageSources.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import EditorStageSources from '@/components/EditorStageSources.vue'
import EditorSource from '@/components/EditorSource.vue'
import Fieldset from '@/components/Fieldset.vue'

import { describe, expect, test, vi } from 'vitest'

describe('EditorStageSources.vue', () => {
describe('should render correctly', () => {
test('should render as much sources as there are in the store', () => {
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/components/EditorToolbar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import EditorToolBar from '@/components/EditorToolBar.vue'
import { EDITOR_UNDO, EDITOR_REDO } from '@/store/mutation-types'
import { NETWORK_STATUS } from '@/constants'

import { describe, expect, test, vi } from 'vitest'

import {
ElButton,
ElDropdown,
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/components/ExportXprv.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import ExportXprv from '@/components/ExportXprv.vue'
import Card from '@/components/card/Card.vue'
import PasswordValidation from '@/components/PasswordValidation.vue'

import { describe, expect, test, vi } from 'vitest'

import { ElButton, ElInput, ElSwitch } from 'element-plus'

describe('ExportXprv', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/src/components/FileUploader.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { shallowMount, mount } from '@vue/test-utils'
import FileUploader from '@/components/FileUploader.vue'
import claimingFileSuccess from '@/TemplateExample.json'
import { describe, expect, test, vi } from 'vitest'

import '../../../../src/fontAwesome'

describe('Renders the correct elements when there is no file uploaded', () => {
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/components/NetworkStatus.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import '@/fontAwesome'
import NetworkStatus from '@/components/NetworkStatus.vue'
import Avatar from '@/components/Avatar.vue'

import { NETWORK_STATUS } from '@/constants'

import { ElButton } from 'element-plus'

describe('NetworkStatus', () => {
Expand Down
14 changes: 8 additions & 6 deletions tests/unit/src/components/ResyncConfirmation.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { flushPromises, mount } from '@vue/test-utils'
import { describe, expect, test, vi } from 'vitest'

import ResyncConfirmation from '@/components/ResyncConfirmation.vue'

import { ElButton, ElDialog } from 'element-plus'
Expand All @@ -14,6 +14,8 @@ describe('ResyncConfirmation.vue', () => {
stubs: {
'el-dialog': ElDialog,
'el-button': ElButton,
teleport: true,
template: true,
},
})
test('should contain an element dialog component', () => {
Expand All @@ -23,24 +25,24 @@ describe('ResyncConfirmation.vue', () => {
})

// Skip until we find a way to make components inside element ui templates visible
test.skip('should contain cancel button', () => {
test('should contain cancel button', () => {
const wrapper = mount(ResyncConfirmation, mockStore)

expect(wrapper.find('[data-test="resync-cancel-btn"]').text()).toBe(
'Cancel',
)
})

// Skip until we find a way to make components inside element ui templates visible
test.skip('should contain confirm button', () => {
// TODO: Skip until we find a way to make components inside element ui templates visible
test.kip('should contain confirm button', () => {
const wrapper = mount(ResyncConfirmation, mockStore)

expect(wrapper.find('[data-test="resync-btn"]').text()).toBe(
'Resynchronize',
)
})

// Skip until we find a way to make components inside element ui templates visible
// TODO: Skip until we find a way to make components inside element ui templates visible
test.skip('should call cancel mutation on click cancel', async () => {
const closeMock = vi.fn()
const resyncMock = vi.fn()
Expand All @@ -67,7 +69,7 @@ describe('ResyncConfirmation.vue', () => {
expect(closeMock).toHaveBeenCalled()
})

// Skip until we find a way to make components inside element ui templates visible
// TODO: Skip until we find a way to make components inside element ui templates visible
test.skip('should call resync action mutation on click confirm', async () => {
const closeMock = vi.fn()
const resyncMock = vi.fn()
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/components/SettingsLanguage.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import SettingsLanguage from '@/components/SettingsLanguage.vue'
import Select from '@/components/Select.vue'

import { describe, expect, test, vi } from 'vitest'

import { LocalStorageWrapper } from '@/api'

describe('SettingsLanguage.vue', () => {
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/components/SettingsNotificationSwitch.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import SettingsNotificationSwitch from '@/components/SettingsNotificationSwitch.vue'

import { describe, expect, test, vi } from 'vitest'

import { ElSwitch } from 'element-plus'

describe('SettingsNotificationSwitch.vue', () => {
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/components/SettingsOptionUnit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import SettingsOptionUnit from '@/components/SettingsOptionUnit.vue'
import Select from '@/components/Select.vue'
import { THEMES } from '@/constants'

import { describe, expect, test, vi } from 'vitest'

describe('SettingsOptionUnit.vue', () => {
describe('change unit', () => {
const changeDefaultUnitMock = vi.fn()
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/components/SettingsResync.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import SettingsResync from '@/components/SettingsResync.vue'
import { NETWORK_STATUS } from '@/constants'

import { describe, expect, test, vi } from 'vitest'

import { ElButton } from 'element-plus'

describe('SettingsResync.vue', () => {
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/components/TransactionList.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import TransactionList from '@/components/TransactionList.vue'
import Transaction from '@/components/Transaction.vue'

import { describe, expect, test, vi } from 'vitest'

import { ElPagination } from 'element-plus'
const setCurrentTransactionsPageActionMock = vi.fn()
const setCurrentTransactionsPageMutationMock = vi.fn()
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/components/setFee.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import SetFee from '@/components/SendTransaction/SetFee.vue'
import SelectEstimatedFee from '@/components/SendTransaction/SelectEstimatedFee.vue'
import { DEFAULT_VTT_VALUES, DEFAULT_LOCALE } from '@/constants'

import { describe, expect, test, vi } from 'vitest'

import { ElButton, ElForm, ElFormItem, ElInput, ElSwitch } from 'element-plus'

const FEE_ESTIMATION_REPORT_MOCK = {
Expand Down
1 change: 0 additions & 1 deletion tests/unit/src/components/steps/WalletDescription.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ describe('WalletDescription.vue', () => {

descriptionInput.setValue('new description')
await flushPromises()
console.log(setWalletDescription.mock.calls)
expect(setWalletDescription.mock.calls[0][1].description).toBe(
'new description',
)
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/services/SyncingTimeEstimator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ describe('formatDuration', () => {
})
}
const oldestSample = estimator.window?.[0]
console.log(oldestSample)
estimator.addSample({ currentBlock: 101 * 50, lastBlock: 101 * 50 + 50 })
console.log(estimator.window[0])
expect(estimator.window[0] !== oldestSample).toBe(true)
}, 30000)
})
Expand Down
24 changes: 12 additions & 12 deletions tests/unit/src/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,31 @@ describe('standardizeTransactionResult', () => {

describe('getDomainFromUrl', () => {
test('should work url with protocol', () => {
const url = 'http://WITnet.io'
const url = 'http://witnet.io'

expect(getDomainFromUrl(url)).toBe('WITnet.io')
expect(getDomainFromUrl(url)).toBe('witnet.io')
})

test('should work without protocol', () => {
const url = 'WITnet.io'
const url = 'witnet.io'

expect(getDomainFromUrl(url)).toBe('WITnet.io')
expect(getDomainFromUrl(url)).toBe('witnet.io')
})

test('should work with subdomain', () => {
const url = 'http://docs.WITnet.io'
const url = 'http://docs.witnet.io'

expect(getDomainFromUrl(url)).toBe('docs.WITnet.io')
expect(getDomainFromUrl(url)).toBe('docs.witnet.io')
})

test('should NOT work without tld', () => {
const url = 'http://WITnet'
const url = 'http://witnet'

expect(getDomainFromUrl(url)).toBe('')
})

test('should NOT work with invalid tld', () => {
const url = 'http://WITnet.abcdefghij'
const url = 'http://witnet.abcdefghij'

expect(getDomainFromUrl(url)).toBe('')
})
Expand Down Expand Up @@ -203,7 +203,7 @@ describe('simplifyDrResult', () => {
})

describe('standardizeWitUnits', () => {
describe('return the value in selected untest', () => {
describe('return the value in selected unit', () => {
describe('WIT', () => {
describe('to WIT', () => {
test('with decimal', () => {
Expand Down Expand Up @@ -1128,9 +1128,9 @@ describe('calculateCurrentFocusAfterRedo', () => {
expect(id).toBe(0)
})

// test('UPDATE_VARIABLE', () => {})
// test('ADD_VARIABLE', () => {})
// test('DELETE_VARIABLE', () => {})
test.todo('UPDATE_VARIABLE', () => {})
test.todo('ADD_VARIABLE', () => {})
test.todo('DELETE_VARIABLE', () => {})
})
})

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/walletVersionCompatibility.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import semver from 'semver'

describe('Semver', () => {
describe('should check wallet version compatibiltesty', () => {
describe('should check wallet version compatibility', () => {
test('gets the version from name', () => {
const name = 'wtestnet-1.2.0'

Expand All @@ -11,7 +11,7 @@ describe('Semver', () => {
expect(result).toBe(expected)
})

test('test should show compatibiltesty if the version is a patch', () => {
test('it should show compatibility if the version is a patch', () => {
const currentWalletVersion = '1.2.0'
const newWalletVersion = '1.2.1'

Expand All @@ -23,7 +23,7 @@ describe('Semver', () => {
expect(result).toBe(true)
})

test('test should result incompatible if the new version is a minor', () => {
test('it should result incompatible if the new version is a minor', () => {
const currentWalletVersion = '1.1.1'
const newWalletVersion = '1.2.1'

Expand All @@ -35,7 +35,7 @@ describe('Semver', () => {
expect(result).toBe(false)
})

test('test should result incompatible if the new version is a major', () => {
test('it should result incompatible if the new version is a major', () => {
const currentWalletVersion = '0.1.1'
const newWalletVersion = '1.2.1'

Expand Down

0 comments on commit 885c14b

Please sign in to comment.