-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathaction.test.ts
More file actions
100 lines (83 loc) · 2.86 KB
/
action.test.ts
File metadata and controls
100 lines (83 loc) · 2.86 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Action test module to check action verbs used.
*/
import * as assert from "assert";
import { lookupDiffIndexAction, moveOrRenameMsg } from "../../generate/action";
test("Desribe a file using a single path", function () {
test("#lookupDiffIndexAction", function () {
test("can describe an updated file", function () {
assert.strictEqual(lookupDiffIndexAction("M"), "update");
});
test("can describe a created file", function () {
assert.strictEqual(lookupDiffIndexAction("A"), "create");
});
test("can describe a deleted file", function () {
assert.strictEqual(lookupDiffIndexAction("D"), "delete");
});
test("can describe a renamed file", function () {
assert.strictEqual(lookupDiffIndexAction("R"), "rename");
});
test("can describe a copied file", function () {
assert.strictEqual(lookupDiffIndexAction("C"), "copy");
});
test("can throws an error for a bad key", function () {
assert.throws(() => lookupDiffIndexAction("Z"));
});
});
});
test("Desribe a file using two paths", function () {
test("#moveOrRenameFile", function () {
test("can describe a renamed file", function () {
assert.strictEqual(
moveOrRenameMsg("foo.txt", "bar.txt"),
"rename foo.txt to bar.txt"
);
assert.strictEqual(
moveOrRenameMsg("buzz/foo.txt", "buzz/bar.txt"),
"rename foo.txt to bar.txt"
);
assert.strictEqual(
moveOrRenameMsg("fizz buzz/foo.txt", "fizz buzz/bar.txt"),
"rename foo.txt to bar.txt"
);
});
test("can describe a moved file", function () {
assert.strictEqual(
moveOrRenameMsg("buzz/foo.txt", "fizz/foo.txt"),
"move foo.txt to fizz"
);
assert.strictEqual(
moveOrRenameMsg("buzz/foo bar.txt", "fizz/foo bar.txt"),
"move 'foo bar.txt' to fizz"
);
assert.strictEqual(
moveOrRenameMsg("buzz/foo.txt", "foo.txt"),
"move foo.txt to repo root"
);
assert.strictEqual(
moveOrRenameMsg("buzz/foo bar.txt", "foo bar.txt"),
"move 'foo bar.txt' to repo root"
);
});
test("can describe a remamed and moved file", function () {
assert.strictEqual(
moveOrRenameMsg("foo.txt", "fizz/bar.txt"),
"move and rename foo.txt to fizz/bar.txt"
);
// This is a rare case, so don't bother trying to handle it smarter around
// paths.
assert.strictEqual(
moveOrRenameMsg("fuzz/foo.txt", "fizz/bar.txt"),
"move and rename foo.txt to fizz/bar.txt"
);
assert.strictEqual(
moveOrRenameMsg("fuzz/foo.txt", "fizz/bar bazz.txt"),
"move and rename foo.txt to 'fizz/bar bazz.txt'"
);
assert.strictEqual(
moveOrRenameMsg("fizz/foo.txt", "bar.txt"),
"move and rename foo.txt to bar.txt at repo root"
);
});
});
});