aboutsummaryrefslogtreecommitdiff
path: root/src/types-test.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-28 01:10:54 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-28 13:46:36 +0200
commit08bd3dc0e8a3c2370e4e8abbaa241eaafc144f4c (patch)
tree9a55a5734718e7c278ccb24733425184fb8cea34 /src/types-test.ts
parent7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (diff)
downloadwallet-core-08bd3dc0e8a3c2370e4e8abbaa241eaafc144f4c.tar.xz
add linting rules and fix them
Diffstat (limited to 'src/types-test.ts')
-rw-r--r--src/types-test.ts75
1 files changed, 45 insertions, 30 deletions
diff --git a/src/types-test.ts b/src/types-test.ts
index 88f9f2723..a84bdaec8 100644
--- a/src/types-test.ts
+++ b/src/types-test.ts
@@ -1,35 +1,51 @@
+/*
+ This file is part of TALER
+ (C) 2017 Inria and GNUnet e.V.
+
+ 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.
+
+ 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
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
import {test} from "ava";
import {Amounts} from "./types";
import * as types from "./types";
-let amt = (value: number, fraction: number, currency: string): types.AmountJson => ({value, fraction, currency});
+const amt = (value: number, fraction: number, currency: string): types.AmountJson => ({value, fraction, currency});
-test("amount addition (simple)", t => {
- let a1 = amt(1,0,"EUR");
- let a2 = amt(1,0,"EUR");
- let a3 = amt(2,0,"EUR");
- t.true(0 == types.Amounts.cmp(Amounts.add(a1, a2).amount, a3));
+test("amount addition (simple)", (t) => {
+ const a1 = amt(1, 0, "EUR");
+ const a2 = amt(1, 0, "EUR");
+ const a3 = amt(2, 0, "EUR");
+ t.true(0 === types.Amounts.cmp(Amounts.add(a1, a2).amount, a3));
t.pass();
});
-test("amount addition (saturation)", t => {
- let a1 = amt(1,0,"EUR");
- let res = Amounts.add(Amounts.getMaxAmount("EUR"), a1);
+test("amount addition (saturation)", (t) => {
+ const a1 = amt(1, 0, "EUR");
+ const res = Amounts.add(Amounts.getMaxAmount("EUR"), a1);
t.true(res.saturated);
t.pass();
});
-test("amount subtraction (simple)", t => {
- let a1 = amt(2,5,"EUR");
- let a2 = amt(1,0,"EUR");
- let a3 = amt(1,5,"EUR");
- t.true(0 == types.Amounts.cmp(Amounts.sub(a1, a2).amount, a3));
+test("amount subtraction (simple)", (t) => {
+ const a1 = amt(2, 5, "EUR");
+ const a2 = amt(1, 0, "EUR");
+ const a3 = amt(1, 5, "EUR");
+ t.true(0 === types.Amounts.cmp(Amounts.sub(a1, a2).amount, a3));
t.pass();
});
-test("amount subtraction (saturation)", t => {
- let a1 = amt(0,0,"EUR");
- let a2 = amt(1,0,"EUR");
+test("amount subtraction (saturation)", (t) => {
+ const a1 = amt(0, 0, "EUR");
+ const a2 = amt(1, 0, "EUR");
let res = Amounts.sub(a1, a2);
t.true(res.saturated);
res = Amounts.sub(a1, a1);
@@ -38,29 +54,29 @@ test("amount subtraction (saturation)", t => {
});
-test("contract validation", t => {
- let c = {
+test("contract validation", (t) => {
+ const c = {
H_wire: "123",
- summary: "hello",
- amount: amt(1,2,"EUR"),
+ amount: amt(1, 2, "EUR"),
auditors: [],
- pay_deadline: "Date(12346)",
- max_fee: amt(1,2,"EUR"),
- merchant_pub: "12345",
exchanges: [{master_pub: "foo", url: "foo"}],
+ fulfillment_url: "foo",
+ max_fee: amt(1, 2, "EUR"),
+ merchant_pub: "12345",
+ order_id: "test_order",
+ pay_deadline: "Date(12346)",
+ pay_url: "https://example.com/pay",
products: [],
refund_deadline: "Date(12345)",
+ summary: "hello",
timestamp: "Date(12345)",
- fulfillment_url: "foo",
wire_method: "test",
- order_id: "test_order",
- pay_url: "https://example.com/pay",
};
types.Contract.checked(c);
- let c1 = JSON.parse(JSON.stringify(c));
- c1.exchanges = []
+ const c1 = JSON.parse(JSON.stringify(c));
+ c1.exchanges = [];
try {
types.Contract.checked(c1);
@@ -70,5 +86,4 @@ test("contract validation", t => {
}
t.fail();
-
});