Skip to content

Commit 54f5ced

Browse files
committed
replace keyword "let" with "const" for constants in effect.
1 parent 0beafbb commit 54f5ced

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

test/OptionalTest.ts

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@ import * as assert from 'power-assert';
33
import Optional from "../lib";
44

55
describe("Optional", () => {
6-
let payload: string = "foo";
7-
let sutPresent: Optional<string> = Optional.ofNonNull(payload);
8-
let sutEmpty: Optional<string> = Optional.empty();
6+
const payload: string = "foo";
7+
const sutPresent: Optional<string> = Optional.ofNonNull(payload);
8+
const sutEmpty: Optional<string> = Optional.empty();
99

1010
describe("#ofNullable", () => {
11-
let getNullable: () => string | null = () => null;
12-
let getUndefinedable: () => string | undefined = () => undefined;
11+
const getNullable: () => string | null = () => null;
12+
const getUndefinedable: () => string | undefined = () => undefined;
1313

1414
it("should return a present optional when it is given a non-null value.", () => {
15-
let sut = Optional.ofNullable("foo");
15+
const sut = Optional.ofNullable("foo");
1616
assert(sut.isPresent);
1717
});
1818

1919
it("should return an empty optional when it receives null.", () => {
20-
let sut: Optional<string> = Optional.ofNullable(getNullable());
20+
const sut: Optional<string> = Optional.ofNullable(getNullable());
2121
assert(sut.isEmpty);
2222
});
2323

2424
it("should return an empty optional when it receives undefined.", () => {
25-
let sut: Optional<string> = Optional.ofNullable(getUndefinedable());
25+
const sut: Optional<string> = Optional.ofNullable(getUndefinedable());
2626
assert(sut.isEmpty);
2727
});
2828
});
2929

3030
describe("#ofNonNull", () => {
3131
it("should return a present optional when it is given a non-null value.", () => {
32-
let sut = Optional.ofNonNull("foo");
32+
const sut = Optional.ofNonNull("foo");
3333
assert(sut.isPresent);
3434
});
3535

@@ -44,7 +44,7 @@ describe("Optional", () => {
4444

4545
describe("#of", () => {
4646
it("should return a present optional when it is given a non-null value.", () => {
47-
let sut = Optional.of("foo");
47+
const sut = Optional.of("foo");
4848
assert(sut.isPresent);
4949
});
5050

@@ -59,7 +59,7 @@ describe("Optional", () => {
5959

6060
describe("#empty", () => {
6161
it("should return an empty optional.", () => {
62-
let sut: Optional<string> = Optional.empty();
62+
const sut: Optional<string> = Optional.empty();
6363
assert(sut.isEmpty);
6464
});
6565
});
@@ -142,32 +142,32 @@ describe("Optional", () => {
142142

143143
describe("#filter", () => {
144144
it("should return a present optional when it is present and the predicate should return true.", () => {
145-
let actual = sutPresent.filter(value => value.length > 0);
145+
const actual = sutPresent.filter(value => value.length > 0);
146146
assert.strictEqual(actual.get(), payload);
147147
});
148148

149149
it("should return an empty optional when it is present and the predicate should return false.", () => {
150-
let actual = sutPresent.filter(value => value.length === 0);
150+
const actual = sutPresent.filter(value => value.length === 0);
151151
assert(actual.isEmpty);
152152
});
153153

154154
it("should return an empty optional when it is empty.", () => {
155-
let actual = sutEmpty.filter(value => true);
155+
const actual = sutEmpty.filter(value => true);
156156
assert(actual.isEmpty);
157157
});
158158
});
159159

160160
describe("#map", () => {
161-
let mapper = (value: string) => value.length;
161+
const mapper = (value: string) => value.length;
162162

163163
it("should return a present optional whose payload is mapped by the given function when it is present.", () => {
164-
let actual = sutPresent.map(mapper).get();
165-
let expected = mapper(payload);
164+
const actual = sutPresent.map(mapper).get();
165+
const expected = mapper(payload);
166166
assert.strictEqual(actual, expected);
167167
});
168168

169169
it("should return an empty optional when it is empty.", () => {
170-
let actual = sutEmpty.map(mapper);
170+
const actual = sutEmpty.map(mapper);
171171
assert(actual.isEmpty);
172172
});
173173

@@ -185,8 +185,8 @@ describe("Optional", () => {
185185

186186
describe("#flatMap", () => {
187187
{
188-
let power = (x: number) => Math.pow(x, 2);
189-
let powerIfPositive: (x: number) => Optional<number> = x => {
188+
const power = (x: number) => Math.pow(x, 2);
189+
const powerIfPositive: (x: number) => Optional<number> = x => {
190190
if (x > 0)
191191
return Optional.ofNonNull(power(x));
192192
else
@@ -195,44 +195,44 @@ describe("Optional", () => {
195195

196196
it("should return the present optional which is mapped by the given function "
197197
+ "when it is present and the function should return present.", () => {
198-
let positive = 42;
199-
let sut = Optional.ofNonNull(positive);
200-
let actual = sut.flatMap(powerIfPositive);
198+
const positive = 42;
199+
const sut = Optional.ofNonNull(positive);
200+
const actual = sut.flatMap(powerIfPositive);
201201
assert.strictEqual(actual.get(), power(positive));
202202
});
203203

204204
it("should return the empty optional which is mapped by the given function "
205205
+ "when it is present and the function should return empty.", () => {
206-
let negative = -42;
207-
let sut = Optional.ofNonNull(negative);
208-
let actual = sut.flatMap(powerIfPositive);
206+
const negative = -42;
207+
const sut = Optional.ofNonNull(negative);
208+
const actual = sut.flatMap(powerIfPositive);
209209
assert(actual.isEmpty);
210210
});
211211

212212
it("should return the empty optional when it is empty.", () => {
213-
let sut = Optional.empty<number>();
214-
let actual = sut.flatMap(powerIfPositive);
213+
const sut = Optional.empty<number>();
214+
const actual = sut.flatMap(powerIfPositive);
215215
assert(actual.isEmpty);
216216
});
217217
}
218218
{
219-
let left: Optional<number> = Optional.ofNonNull(3);
220-
let right: Optional<number> = Optional.ofNonNull(4);
221-
let empty: Optional<number> = Optional.empty();
222-
let sum = left.get() + right.get();
219+
const left: Optional<number> = Optional.ofNonNull(3);
220+
const right: Optional<number> = Optional.ofNonNull(4);
221+
const empty: Optional<number> = Optional.empty();
222+
const sum = left.get() + right.get();
223223

224224
it("should return value of applying bi-function to two payloads when both of the two optionals are present.", () => {
225-
let actual = left.flatMap(x => right.map(y => x + y));
225+
const actual = left.flatMap(x => right.map(y => x + y));
226226
assert.strictEqual(actual.get(), sum);
227227
});
228228

229229
it("should return empty optional when the left is present and the right is empty.", () => {
230-
let actual = left.flatMap(x => empty.map(y => x + y));
230+
const actual = left.flatMap(x => empty.map(y => x + y));
231231
assert(actual.isEmpty);
232232
});
233233

234234
it("should return empty optional when the left is empty and the right is present.", () => {
235-
let actual = empty.flatMap(x => right.map(y => x + y));
235+
const actual = empty.flatMap(x => right.map(y => x + y));
236236
assert(actual.isEmpty);
237237
});
238238
}
@@ -254,36 +254,36 @@ describe("Optional", () => {
254254
});
255255

256256
describe("#orElse", () => {
257-
let another = "bar";
257+
const another = "bar";
258258

259259
it("should return the original payload when it is present.", () => {
260-
let actual = sutPresent.orElse(another);
260+
const actual = sutPresent.orElse(another);
261261
assert.strictEqual(actual, sutPresent.get());
262262
});
263263

264264
it("should return the given value when it is empty.", () => {
265-
let actual = sutEmpty.orElse(another);
265+
const actual = sutEmpty.orElse(another);
266266
assert.strictEqual(actual, another);
267267
});
268268
});
269269

270270
describe("#orElseGet", () => {
271-
let another = "bar";
271+
const another = "bar";
272272

273273
it("should return the original payload when it is present.", () => {
274-
let actual = sutPresent.orElseGet(() => another);
274+
const actual = sutPresent.orElseGet(() => another);
275275
assert.strictEqual(actual, sutPresent.get());
276276
});
277277

278278
it("should return the value returned by the given function when it is empty.", () => {
279-
let actual = sutEmpty.orElseGet(() => another);
279+
const actual = sutEmpty.orElseGet(() => another);
280280
assert.strictEqual(actual, another);
281281
});
282282
});
283283

284284
describe("#orElseThrow", () => {
285285
it("should return the original payload when it is present.", () => {
286-
let actual = sutPresent.orElseThrow(TypeError);
286+
const actual = sutPresent.orElseThrow(TypeError);
287287
assert.strictEqual(actual, sutPresent.get());
288288
});
289289

0 commit comments

Comments
 (0)