-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_smart_test.dart
76 lines (74 loc) · 2.77 KB
/
get_smart_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import "package:flutter_test/flutter_test.dart";
import "package:get_smart/get_smart.dart";
void main() {
test("Test StringX: surround", () {
const text = "hello";
expect(text.surround("*"), "*hello*");
expect(text.surround("*", doFor: 2), "**hello**");
expect(text.surround("*", doFor: 3), "***hello***");
expect(text.surround("*", between: " "), "* hello *");
expect(text.surround(null), "hello");
expect(text.surround("*", doIf: false), "hello");
});
test("Test StringX: pre", () {
const text = "hello";
expect(text.pre("*"), "*hello");
expect(text.pre("*", doFor: 2), "**hello");
expect(text.pre("*", doFor: 3), "***hello");
expect(text.pre("*", between: " "), "* hello");
expect(text.pre(null), "hello");
expect(text.pre("*", doIf: false), "hello");
});
test("Test StringX: post", () {
const text = "hello";
expect(text.post("*"), "hello*");
expect(text.post("*", doFor: 2), "hello**");
expect(text.post("*", doFor: 3), "hello***");
expect(text.post("*", between: " "), "hello *");
expect(text.post(null), "hello");
expect(text.post("*", doIf: false), "hello");
});
test("Test StringX: takeInitials", () {
const text1 = "Hello World ( Greetings ) - Program";
expect(text1.takeInitials(1), "H");
expect(text1.takeInitials(2), "HW");
expect(text1.takeInitialsWithoutGarbage(3), "HWG");
expect(text1.takeInitials(4), "HW(G");
expect(text1.takeInitialsWithoutGarbage(5), "HWGP");
expect(text1.takeInitialsWithoutGarbage(5, fill: true), "HELLO");
const text2 = "Text 2";
expect(text2.takeInitials(5, fill: true), "TEXT");
expect(text2.takeInitials(5), "T2");
});
test("Test BoolTransform:", () {
final boolTransform = BoolTransform();
expect(boolTransform.fromJson(true), true);
expect(boolTransform.fromJson("true"), true);
expect(boolTransform.fromJson("Yes"), true);
expect(boolTransform.fromJson("Y"), true);
expect(boolTransform.fromJson(false), false);
expect(boolTransform.fromJson("false"), false);
expect(boolTransform.fromJson("No"), false);
expect(boolTransform.fromJson("N"), false);
expect(boolTransform.toJson(true), "Y");
expect(boolTransform.toJson(false), "N");
});
test("Test DateFormatX:", () {
final date = Date.from(
day: 1,
month: 2,
year: 2021,
hour: 1,
minute: 10,
second: 0,
microsecond: 0,
millisecond: 0,
);
var time = Date.from(hour: 18, minute: 20, second: 0);
expect(date.setting(time: time).formatYMMdHms, "2021-02-01 18:20:00");
expect(date.setting(time: time).formatDMMyHm, "01-02-2021 18:20");
expect(date.setting(time: time).formatHm, "18:20");
expect(date.formatHm, "01:10");
expect(date.formatDMMy, "01-02-2021");
});
}