2022-03-23 21:50:06 +01:00
|
|
|
/*
|
|
|
|
This file is part of GNU Taler
|
|
|
|
(C) 2021 Taler Systems S.A.
|
|
|
|
|
|
|
|
GNU Taler is free software; you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 3, or (at your option) any later version.
|
|
|
|
|
|
|
|
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author Sebastian Javier Marchano (sebasjm)
|
|
|
|
*/
|
|
|
|
|
2022-03-29 14:58:06 +02:00
|
|
|
import { Amounts, Balance } from "@gnu-taler/taler-util";
|
2022-03-29 17:18:58 +02:00
|
|
|
import { DepositGroupFees } from "@gnu-taler/taler-wallet-core/src/operations/deposits";
|
2022-03-23 21:50:06 +01:00
|
|
|
import { expect } from "chai";
|
2022-03-29 04:41:07 +02:00
|
|
|
import { mountHook } from "../test-utils.js";
|
2022-03-29 14:58:06 +02:00
|
|
|
import { useComponentState } from "./DepositPage.js";
|
2022-03-23 21:50:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
const currency = "EUR"
|
2022-03-29 17:18:58 +02:00
|
|
|
const feeCalculator = async (): Promise<DepositGroupFees> => ({
|
2022-03-23 21:50:06 +01:00
|
|
|
coin: Amounts.parseOrThrow(`${currency}:1`),
|
|
|
|
wire: Amounts.parseOrThrow(`${currency}:1`),
|
|
|
|
refresh: Amounts.parseOrThrow(`${currency}:1`)
|
|
|
|
})
|
|
|
|
|
|
|
|
const someBalance = [{
|
|
|
|
available: 'EUR:10'
|
|
|
|
} as Balance]
|
|
|
|
|
|
|
|
describe("DepositPage states", () => {
|
|
|
|
it("should have status 'no-balance' when balance is empty", () => {
|
2022-04-11 16:36:32 +02:00
|
|
|
const { getLastResultOrThrow } = mountHook(() =>
|
2022-03-23 21:50:06 +01:00
|
|
|
useComponentState(currency, [], [], feeCalculator),
|
|
|
|
);
|
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
{
|
|
|
|
const { status } = getLastResultOrThrow()
|
|
|
|
expect(status).equal("no-balance")
|
2022-03-23 21:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should have status 'no-accounts' when balance is not empty and accounts is empty", () => {
|
2022-04-11 16:36:32 +02:00
|
|
|
const { getLastResultOrThrow } = mountHook(() =>
|
2022-03-23 21:50:06 +01:00
|
|
|
useComponentState(currency, [], someBalance, feeCalculator),
|
|
|
|
);
|
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
{
|
|
|
|
const { status } = getLastResultOrThrow()
|
|
|
|
expect(status).equal("no-accounts")
|
2022-03-23 21:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|