Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bassemmagdy committed Dec 23, 2021
1 parent 673aad4 commit 226f83e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getComponent } from '@MOCKS/Components';
import AccountStore from '@/store/Account';
import TransactionStore from '@/store/Transaction';
import AddressBookStore from '@/store/AddressBook';
import { AddressBook, IContact } from 'symbol-address-book';
import { getTestAccount } from '@MOCKS/Accounts';
let wrapper;
let vm;
Expand Down Expand Up @@ -55,4 +54,27 @@ describe('TransactionListFilters', () => {
});
expect(vm.$store.commit).toBeCalledWith('transaction/isBlackListFilterActivated', !isBlackListFilterActivated);
});

test("should call 'transaction/filterTransactions'", () => {
wrapper = getComponent(
TransactionListFilters,
{ account: AccountStore, transaction: TransactionStore, addressBook: AddressBookStore },
{
currentAccount: null,
currentAccountSigner: currentSigner,
addressBook: addressBookMock,
isBlackListFilterActivated: true,
signers: [],
},
{},
{},
);
vm = wrapper.vm as TransactionListFilters;
vm.onSelectBlackListed();
expect(vm.$store.commit).toBeCalledWith('transaction/filterTransactions', {
currentSignerAddress: currentSigner.address.plain(),
filterOption: null,
});
expect(vm.$store.commit).toBeCalledWith('transaction/isBlackListFilterActivated', false);
});
});
10 changes: 5 additions & 5 deletions __tests__/services/TransactionFilterService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ import { addressBookMock } from '@MOCKS/AddressBookMock';
import { IContact } from 'symbol-address-book';

const currentSigner = getTestAccount('remoteTestnet');
const recepient = getTestAccount('remoteTestnetRecipient');
const recipient = getTestAccount('remoteTestnetRecipient');
const sentTransaction = {
signer: currentSigner,
recipientAddress: {
address: currentSigner.address.plain(),
},
};
const receivedTransaction = {
signer: recepient,
signer: recipient,
recipientAddress: {
address: currentSigner.address.plain(),
address: recipient.address.plain(),
},
};

Expand Down Expand Up @@ -106,15 +106,15 @@ describe('services/TransactionFilterService', () => {
transactionState.filterOptions.isReceivedSelected = true;
const result = TransactionFilterService.filter(transactionState, currentSigner.address.plain());

expect(result.length).toBe(2);
expect(result.length).toBe(1);
done();
});

test('should return transactions only received from blacklisted contacts', async (done) => {
const addressBook = addressBookMock;
const contact1: IContact = {
id: '5c9093c7-2da2-476e-bc28-87f24a83cd23',
address: recepient.address.plain(),
address: recipient.address.plain(),
name: 'BlackListed',
phone: '+34 000000000',
isBlackListed: true,
Expand Down
4 changes: 2 additions & 2 deletions __tests__/utils/CommonHelpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ describe('utils/CommonHelpers', () => {
test('returns truncated string', () => {
const address = Address.createFromRawAddress('TAD5BAHLOIXCRRB6GU2H72HPXMBBVAEUQRYPHBY');
const truncatedAddress = CommonHelpers.truncate(address.plain());
const string = 'string';
const string = 'shortString';
expect(truncatedAddress.length).toBe(15);
expect(truncatedAddress.substring(truncatedAddress.length - 6)).toEqual('...HBY');
expect(CommonHelpers.truncate(string).length).toBe(6);
expect(CommonHelpers.truncate(string).length).toBe(11);
});
});
});

0 comments on commit 226f83e

Please sign in to comment.