-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod_test.ts
60 lines (57 loc) · 2.31 KB
/
mod_test.ts
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
import { test, runIfMain } from "https://deno.land/std/testing/mod.ts";
import { assert, assertEquals } from "https://deno.land/std/testing/asserts.ts";
import { validate, format, caseStyle } from "./mod.ts";
test({
name: "[string] Case style validator",
fn(): void {
assert(validate("jaime-les-fruits-au-sirop", caseStyle.kebabCase));
assert(validate("jaime_les_fruits_au_sirop", caseStyle.snakeCase));
assert(validate("jaimeLesFruitsAuSirop", caseStyle.camelCase));
assert(validate("JaimeLesFruitsAuSirop", caseStyle.pascalCase));
assert(validate("DIZ_IZ_DA_GLOBAL_VAL", caseStyle.screamingSnakeCase));
assert(validate("SALADE-TOMATE-OIGNONS", caseStyle.screamingKebabCase));
assert(!validate("OhMyGodASnake", caseStyle.snakeCase));
assert(!validate("imNotPascal", caseStyle.pascalCase));
assert(!validate("SmokingIsBad", caseStyle.camelCase));
assert(!validate("salade_TomateOignons", caseStyle.kebabCase));
assert(
!validate("jaime-les-fruits-au-sirop", caseStyle.screamingSnakeCase)
);
assert(
!validate("jaime_les_fruits_au_sirop", caseStyle.screamingKebabCase)
);
}
});
test({
name: "[string] Case style formater",
fn(): void {
const input = `deja vu i've just been in this place before
Higher on the street
And I know it's my time to go…`;
assertEquals(
format(input, caseStyle.kebabCase),
"deja-vu-i-ve-just-been-in-this-place-before-higher-on-the-street-and-i-know-it-s-my-time-to-go"
);
assertEquals(
format(input, caseStyle.snakeCase),
"deja_vu_i_ve_just_been_in_this_place_before_higher_on_the_street_and_i_know_it_s_my_time_to_go"
);
assertEquals(
format(input, caseStyle.camelCase),
"dejaVuIVeJustBeenInThisPlaceBeforeHigherOnTheStreetAndIKnowItSMyTimeToGo"
);
assertEquals(
format(input, caseStyle.pascalCase),
"DejaVuIVeJustBeenInThisPlaceBeforeHigherOnTheStreetAndIKnowItSMyTimeToGo"
);
assertEquals(
format(input, caseStyle.screamingSnakeCase),
"DEJA_VU_I_VE_JUST_BEEN_IN_THIS_PLACE_BEFORE_HIGHER_ON_THE_STREET_AND_I_KNOW_IT_S_MY_TIME_TO_GO"
);
assertEquals(
format(input, caseStyle.screamingKebabCase),
"DEJA-VU-I-VE-JUST-BEEN-IN-THIS-PLACE-BEFORE-HIGHER-ON-THE-STREET-AND-I-KNOW-IT-S-MY-TIME-TO-GO"
);
}
});
runIfMain(import.meta);