Skip to content

Commit

Permalink
Lint tests #218
Browse files Browse the repository at this point in the history
  • Loading branch information
gamalielhere committed Dec 11, 2018
1 parent c3c8fd8 commit 3320f6f
Show file tree
Hide file tree
Showing 85 changed files with 3,609 additions and 3,355 deletions.
1 change: 0 additions & 1 deletion .eslintignore
@@ -1,4 +1,3 @@
/dist/
/*.js
/tests/unit/coverage/
/tests/
9 changes: 2 additions & 7 deletions tests/unit/helpers/index.js
@@ -1,12 +1,7 @@
// import TestValues from './testValues'
import Tooling from './setupTooling'
import Tooling from './setupTooling';
import Mnemonic from './testValues/mnemonic';
import JsonFile from './testValues/jsonFile';
import PrivateKey from './testValues/privateKey';

export {
Mnemonic,
JsonFile,
PrivateKey,
Tooling
}
export { Mnemonic, JsonFile, PrivateKey, Tooling };
45 changes: 20 additions & 25 deletions tests/unit/helpers/mockStore.js
Expand Up @@ -6,7 +6,6 @@ const state = {
ens: true,
Errors: {},
ethDonationAddress: '0xDECAF9CD2367cdbb726E904cD6397eDFcAe6068D',
gasPrice: gasPrice,
Networks: {},
network: {},
notifications: {},
Expand All @@ -20,51 +19,47 @@ const state = {

const getters = {
account: () => {
return {balance: 0}
return { balance: 0 };
},
customPaths: () => {},
ens: () => {},
Errors: () => {},
ethDonationAddress: () => '',
gasPrice: () => 41,
gasPrice: () => 41,
Networks: () => {},
network: () => {
return {
auth:false,
password:"",
port:443,
service:"infura.io",
type:{
blockExplorerAddr:"https://etherscan.io/address/[[address]]",
blockExplorerTX:"https://etherscan.io/tx/[[txHash]]",
chainID:1,
auth: false,
password: '',
port: 443,
service: 'infura.io',
type: {
blockExplorerAddr: 'https://etherscan.io/address/[[address]]',
blockExplorerTX: 'https://etherscan.io/tx/[[txHash]]',
chainID: 1,
contracts: [],
ensResolver:"0x314159265dd8dbb310642f98f50c066173c1259b",
homePage:"https://ethereum.org",
name:"ETH",
name_long:"Ethereum",
tokens:[]
ensResolver: '0x314159265dd8dbb310642f98f50c066173c1259b',
homePage: 'https://ethereum.org',
name: 'ETH',
name_long: 'Ethereum',
tokens: []
},
url:"https://mainnet.infura.io/mew",
}
url: 'https://mainnet.infura.io/mew'
};
},
notifications: () => {},
online: () => true,
Transactions: () => {},
wallet: () => {
return {
getChecksumAddressString: () => ''
}
};
},
web3: () => {
return {
eth: {}
}
};
}
};


export {
state,
getters
}
export { state, getters };
2 changes: 1 addition & 1 deletion tests/unit/helpers/setupTooling.js
@@ -1,4 +1,4 @@
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { createLocalVue } from '@vue/test-utils';
import VueI18n from 'vue-i18n';
import BootstrapVue from 'bootstrap-vue';
import VueX from 'vuex';
Expand Down
50 changes: 31 additions & 19 deletions tests/unit/helpers/testValues/jsonFile.js
@@ -1,31 +1,43 @@
const content = {
'version': 3,
'id': '82b3808e-92cd-45f9-8a1d-e60b129d9cbb',
'address': '09386c7cd7fc28479d81a0551d149ea20ca56460',
'crypto': {
'ciphertext': '07550b2704c50033c37f3cf614a849c2f7486b88438d839b2ceaf3ddc8166f22',
'cipherparams': { 'iv': '90561e0e22c138a0f70251ce3d1c04fa' },
'cipher': 'aes-128-ctr',
'kdf': 'scrypt',
'kdfparams': {
'dklen': 32,
'salt': 'ae157b7f6233e9b84f8663732187083f24a360f69096816badccf05a3783e785',
'n': 131072,
'r': 8,
'p': 1
version: 3,
id: '82b3808e-92cd-45f9-8a1d-e60b129d9cbb',
address: '09386c7cd7fc28479d81a0551d149ea20ca56460',
crypto: {
ciphertext:
'07550b2704c50033c37f3cf614a849c2f7486b88438d839b2ceaf3ddc8166f22',
cipherparams: { iv: '90561e0e22c138a0f70251ce3d1c04fa' },
cipher: 'aes-128-ctr',
kdf: 'scrypt',
kdfparams: {
dklen: 32,
salt: 'ae157b7f6233e9b84f8663732187083f24a360f69096816badccf05a3783e785',
n: 131072,
r: 8,
p: 1
},
'mac': '1853b643514e6d11fd2968dd4996caf1d82b386cfdb1b0a6d296ce5810096a95'
mac: '1853b643514e6d11fd2968dd4996caf1d82b386cfdb1b0a6d296ce5810096a95'
}
};

const contentAsString = '{"version":3,"id":"82b3808e-92cd-45f9-8a1d-e60b129d9cbb","address":"09386c7cd7fc28479d81a0551d149ea20ca56460","crypto":{"ciphertext":"07550b2704c50033c37f3cf614a849c2f7486b88438d839b2ceaf3ddc8166f22","cipherparams":{"iv":"90561e0e22c138a0f70251ce3d1c04fa"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"ae157b7f6233e9b84f8663732187083f24a360f69096816badccf05a3783e785","n":131072,"r":8,"p":1},"mac":"1853b643514e6d11fd2968dd4996caf1d82b386cfdb1b0a6d296ce5810096a95"}}';
const contentAsString =
'{"version":3,"id":"82b3808e-92cd-45f9-8a1d-e60b129d9cbb","address":"09386c7cd7fc28479d81a0551d149ea20ca56460","crypto":{"ciphertext":"07550b2704c50033c37f3cf614a849c2f7486b88438d839b2ceaf3ddc8166f22","cipherparams":{"iv":"90561e0e22c138a0f70251ce3d1c04fa"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"ae157b7f6233e9b84f8663732187083f24a360f69096816badccf05a3783e785","n":131072,"r":8,"p":1},"mac":"1853b643514e6d11fd2968dd4996caf1d82b386cfdb1b0a6d296ce5810096a95"}}';

const address = '0x09386C7Cd7FC28479d81a0551D149eA20CA56460';
const privateKey = 'fc3c01054fe0a3ece1cc7678e2e825dc67a3f4e561d4429ea606871cabd1b2d3';
const privateKey =
'fc3c01054fe0a3ece1cc7678e2e825dc67a3f4e561d4429ea606871cabd1b2d3';
const password = '123456789';

const rawTransactionDetails = {"nonce":"0x00","gasPrice":"0xb2d05e00","gasLimit":"0x5208","to":"0x09386C7Cd7FC28479d81a0551D149eA20CA56460","value":"0x0de0b6b3a7640000","data":"0x","chainId":1};
const transaction = '0xf86b8084b2d05e008252089409386c7cd7fc28479d81a0551d149ea20ca56460880de0b6b3a76400008025a0f99f353b834839adcf82a4263366790109a0910b13ffa1b09254556787eaf099a0116ebde2d2e0fca9d786660e90edc912bc64cda4541bb2d598628cdcf0add0a8';
const rawTransactionDetails = {
nonce: '0x00',
gasPrice: '0xb2d05e00',
gasLimit: '0x5208',
to: '0x09386C7Cd7FC28479d81a0551D149eA20CA56460',
value: '0x0de0b6b3a7640000',
data: '0x',
chainId: 1
};
const transaction =
'0xf86b8084b2d05e008252089409386c7cd7fc28479d81a0551d149ea20ca56460880de0b6b3a76400008025a0f99f353b834839adcf82a4263366790109a0910b13ffa1b09254556787eaf099a0116ebde2d2e0fca9d786660e90edc912bc64cda4541bb2d598628cdcf0add0a8';

export default {
content,
Expand Down
10 changes: 6 additions & 4 deletions tests/unit/helpers/testValues/mnemonic.js
@@ -1,5 +1,5 @@

const short = 'prevent creek catch size lunch burger pledge model fish violin kidney grape';
const short =
'prevent creek catch size lunch burger pledge model fish violin kidney grape';
const shortPassword = '123456789';
const shortAddresses = [
'0x44279a211cA26DFefC80CB3aFE2aD29Cf5f4e77c',
Expand All @@ -8,15 +8,17 @@ const shortAddresses = [
'0x825c234066CeaF501662C080DDa659fed6F85795',
'0x10897D50c894A378F3C6DF46F46Bd9eA62665803'
];
const noPasswordShort = 'ship unable still piano option canyon fury tide pact city clinic gallery';
const noPasswordShort =
'ship unable still piano option canyon fury tide pact city clinic gallery';
const noPasswordShortAddresses = [
'0x5671211E3B2F76724C0293b2B2caABcEDCd2eB9A',
'0x77F14E2F1D5895036E005A6E957CcFF2e812AFff',
'0x08cE3B3B84a5Cd05d66d7bf8612218CC03570821',
'0x29693c8244FFb298E023Ae0d1e3a089B691917f9',
'0x4B35C3beCee3F14447A8304479C56c6376D53110'
];
const long = 'mass exit spell grace barely educate carpet mother catalog broken allow better grief off normal interest diesel rude runway extra absorb layer verb amused';
const long =
'mass exit spell grace barely educate carpet mother catalog broken allow better grief off normal interest diesel rude runway extra absorb layer verb amused';
const longPassword = '123456789';
const longAddresses = [
'0x08a4e770a8A8C5FA179a7E3B394Ba0AEdDc65Cc1',
Expand Down
17 changes: 9 additions & 8 deletions tests/unit/helpers/testValues/privateKey.js
Expand Up @@ -2,15 +2,16 @@ const key = 'b7420d4287f425479375c7f6eab7338cabd8a61c7b85fd51b00dac3d7443a8ea';
const address = '0xB783eA3D37757f201C8e46dB7A30fB9dDe4EeCd3';

const rawTransactionDetails = {
'nonce': '0x00',
'gasPrice': '0xb2d05e00',
'gasLimit': '0x5208',
'to': '0xB783eA3D37757f201C8e46dB7A30fB9dDe4EeCd3',
'value': '0x0de0b6b3a7640000',
'data': '0x',
'chainId': 1
nonce: '0x00',
gasPrice: '0xb2d05e00',
gasLimit: '0x5208',
to: '0xB783eA3D37757f201C8e46dB7A30fB9dDe4EeCd3',
value: '0x0de0b6b3a7640000',
data: '0x',
chainId: 1
};
const transaction = '0xf86b8084b2d05e0082520894b783ea3d37757f201c8e46db7a30fb9dde4eecd3880de0b6b3a76400008026a03134357a75fe5b7335cbbfd775b47a1000cc061537b2c97bdaa1bf5a5841e5b4a0602319cb35b60e2c8bf2ccee2ad3b4f695c2aa5c9c90129eb1047380db811440';
const transaction =
'0xf86b8084b2d05e0082520894b783ea3d37757f201c8e46db7a30fb9dde4eecd3880de0b6b3a76400008026a03134357a75fe5b7335cbbfd775b47a1000cc061537b2c97bdaa1bf5a5841e5b4a0602319cb35b60e2c8bf2ccee2ad3b4f695c2aa5c9c90129eb1047380db811440';

export default {
key,
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/specs/src/components/Blockie/Blockie.spec.js
@@ -1,11 +1,10 @@
import Vue from 'vue';
import Blockie from '@/components/Blockie';
import { mount, shallowMount } from '@vue/test-utils';

import { Tooling } from '@@/helpers';

describe('Blockie.vue', () => {
let localVue, i18n, wrapper, store;
let localVue, i18n, store;
const address = '0xDECAF9CD2367cdbb726E904cD6397eDFcAe6068D';

beforeAll(() => {
Expand All @@ -16,7 +15,7 @@ describe('Blockie.vue', () => {
});

beforeEach(() => {
wrapper = shallowMount(Blockie, {
shallowMount(Blockie, {
localVue,
i18n,
store,
Expand Down
@@ -1,40 +1,33 @@
import Vue from 'vue';
import ButtonWithQrCode from '@/components/Buttons/ButtonWithQrCode/ButtonWithQrCode.vue';
import { shallowMount } from '@vue/test-utils'
import QrcodeIcon from '@/assets/images/icons/qr-code.svg';
import {
Tooling
} from '@@/helpers';
import { shallowMount } from '@vue/test-utils';
import { Tooling } from '@@/helpers';

describe('ButtonWithQrCode.vue', () => {
let localVue, i18n, wrapper, store;
const buttonname = 'QRCode';
const qrcode = 'qrcode';
beforeAll(() => {
const baseSetup = Tooling.createLocalVueInstance();
localVue = baseSetup.localVue;
i18n = baseSetup.i18n;
store = baseSetup.store;

});
let localVue, i18n, wrapper, store;
const buttonname = 'QRCode';
const qrcode = 'qrcode';
beforeAll(() => {
const baseSetup = Tooling.createLocalVueInstance();
localVue = baseSetup.localVue;
i18n = baseSetup.i18n;
store = baseSetup.store;
});

beforeEach(() => {
wrapper = shallowMount(ButtonWithQrCode, {
localVue,
i18n,
store,
attachToDocument: true,
propsData: { buttonname , qrcode}
});
beforeEach(() => {
wrapper = shallowMount(ButtonWithQrCode, {
localVue,
i18n,
store,
attachToDocument: true,
propsData: { buttonname, qrcode }
});
});

it('should render correct contents', () => {
expect(wrapper.vm.$el.querySelector('div div .the-button').textContent.trim()).toEqual(buttonname);
expect(
wrapper.vm.$el.querySelector('div div .the-button').textContent.trim()
).toEqual(buttonname);
});

describe('ButtonWithQrCode.vue Methods', () => {});
});




@@ -1,11 +1,10 @@
import Vue from 'vue';
import DropDownAddressSelector from '@/components/DropDownAddressSelector/DropDownAddressSelector.vue';
import { shallowMount } from '@vue/test-utils';

import { Tooling } from '@@/helpers';

describe('DropDownAddressSelector.vue', () => {
let localVue, i18n, wrapper, store;
let localVue, i18n, store;

beforeAll(() => {
const baseSetup = Tooling.createLocalVueInstance();
Expand All @@ -15,7 +14,7 @@ describe('DropDownAddressSelector.vue', () => {
});

beforeEach(() => {
wrapper = shallowMount(DropDownAddressSelector, {
shallowMount(DropDownAddressSelector, {
localVue,
i18n,
store,
Expand All @@ -31,7 +30,7 @@ describe('DropDownAddressSelector.vue', () => {
const addressElements = wrapper.vm.$el.querySelectorAll(
'.dropdown-list-box .listed-address'
);
for (var i = 0; i < addressElements.length; i++) {
for (let i = 0; i < addressElements.length; i++) {
const addressElement = addressElements[i];
expect(addressElement.textContent.trim()).toEqual(
`${wrapper.vm.$data.addresses[i].slice(
Expand Down

0 comments on commit 3320f6f

Please sign in to comment.