Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lykhoyda committed Apr 19, 2024
1 parent 2bd0c5b commit d49dc4e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class AddressInput extends BaseComponent {
<span>Send to </span>
${when(
this.errorMessage,
() => html` <span class="errorMessage">${this.errorMessage}</span>`
() => html`<span class="errorMessage">${this.errorMessage}</span>`
)}</label
>
<textarea
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class FungibleTokenTransferController implements ReactiveController {
onDestinationAddressChange = (address: string): void => {
this.destinationAddress = address;

if (this.destinationAddress.length === 0) {
if (this.destinationAddress && this.destinationAddress.length === 0) {
this.pendingEvmApprovalTransactions = [];
this.pendingEvmTransferTransaction = undefined;
this.destinationAddress = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { html } from 'lit';
import { Network } from '@buildwithsygma/sygma-sdk-core';
import { AddressInput } from '../../../../src/components';

const errorMessageInvalidAddress = 'invalid Ethereum address';

describe('address-input component', function () {
afterEach(() => {
fixtureCleanup();
Expand Down Expand Up @@ -112,13 +110,9 @@ describe('address-input component', function () {
await listener;

assert.equal(mockAddressChangeHandler.mock.calls.length, 3);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], [
'0x123',
errorMessageInvalidAddress
]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['0x123']);
assert.deepEqual(mockAddressChangeHandler.mock.lastCall, [
'0xebFC7A970CAAbC18C8e8b7367147C18FC7585492',
null
'0xebFC7A970CAAbC18C8e8b7367147C18FC7585492'
]);
});

Expand All @@ -143,8 +137,8 @@ describe('address-input component', function () {
await listener;

assert.equal(mockAddressChangeHandler.mock.calls.length, 3);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[1], ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['']);
assert.deepEqual(mockAddressChangeHandler.mock.calls[1], ['']);

const errorMessage = el.shadowRoot!.querySelector(
'.errorMessage'
Expand All @@ -160,10 +154,9 @@ describe('address-input component', function () {

assert.equal(mockAddressChangeHandler.mock.calls.length, 4);
assert.deepEqual(mockAddressChangeHandler.mock.calls[2], [
'0xebFC7A970CAAbC18C8e8b7367147C18FC7',
errorMessageInvalidAddress
'0xebFC7A970CAAbC18C8e8b7367147C18FC7'
]);
assert.deepEqual(mockAddressChangeHandler.mock.lastCall, ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.lastCall, ['']);

const errorMessageAfterClean = el.shadowRoot!.querySelector(
'.errorMessage'
Expand Down Expand Up @@ -195,10 +188,9 @@ describe('address-input component', function () {
await listener;

assert.equal(mockAddressChangeHandler.mock.calls.length, 3);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['']);
assert.deepEqual(mockAddressChangeHandler.mock.lastCall, [
'42sydUvocBuEorweEPqxY5vZae1VaTtWoJFiKMrPbRamy2BL',
null
'42sydUvocBuEorweEPqxY5vZae1VaTtWoJFiKMrPbRamy2BL'
]);
});

Expand All @@ -224,10 +216,9 @@ describe('address-input component', function () {
await listener;

assert.equal(mockAddressChangeHandler.mock.calls.length, 3);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['']);
assert.deepEqual(mockAddressChangeHandler.mock.lastCall, [
'0xebFC7A970CAAbC18C8e8b7367147C18FC7585492',
null
'0xebFC7A970CAAbC18C8e8b7367147C18FC7585492'
]);
});

Expand All @@ -254,8 +245,8 @@ describe('address-input component', function () {
await listener;

assert.equal(mockAddressChangeHandler.mock.calls.length, 3);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[1], ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['']);
assert.deepEqual(mockAddressChangeHandler.mock.calls[1], ['']);

const errorMessage = el.shadowRoot!.querySelector(
'.errorMessage'
Expand Down Expand Up @@ -286,8 +277,8 @@ describe('address-input component', function () {
await listener;

assert.equal(mockAddressChangeHandler.mock.calls.length, 3);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[1], ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['']);
assert.deepEqual(mockAddressChangeHandler.mock.calls[1], ['']);

const errorMessage = el.shadowRoot!.querySelector(
'.errorMessage'
Expand Down Expand Up @@ -317,8 +308,8 @@ describe('address-input component', function () {
await listener;

assert.equal(mockAddressChangeHandler.mock.calls.length, 3);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[1], ['', null]);
assert.deepEqual(mockAddressChangeHandler.mock.calls[0], ['']);
assert.deepEqual(mockAddressChangeHandler.mock.calls[1], ['']);

el.networkType = Network.SUBSTRATE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ describe('Fungible token Transfer', function () {
'sygma-address-input'
) as AddressInput;

assert(sygmaAddressInput.address === '');
assert.equal(sygmaAddressInput.address, '');
});
});

0 comments on commit d49dc4e

Please sign in to comment.