generated from windingwind/zotero-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtoSentenseCase.test.ts
79 lines (76 loc) · 3.28 KB
/
toSentenseCase.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { toSentenceCase } from "../src/utils/str";
import { expect, test } from "vitest";
/**
* Test item / 测试项目信息
* @property name - 条目名称
* @property original - The input original text / 输入的原始文本
* @property expected - The expected text / 期望得到的文本
*/
interface testItem {
name: string;
original: string;
expected: string;
}
const testItems: testItem[] = [
{
name: "常规转为句首大写",
original: `Heterogeneous Catalytic Decomposition of Nitrous Oxides`,
expected: `Heterogeneous catalytic decomposition of nitrous oxides`,
},
{
name: "虚词应始终保持小写",
original: `Heterogeneous Catalytic Decomposition Of Nitrous Oxides`,
expected: `Heterogeneous catalytic decomposition of nitrous oxides`,
},
{
name: "带有上下标的部分保持大小写",
original: `Catalytic Decomposition of N<sub>2</sub>O on Ordered Crystalline Metal Oxides`,
expected: `Catalytic decomposition of N<sub>2</sub>O on ordered crystalline metal oxides`,
},
{
name: "上下标前有连字符的也应保持大小写",
original: `Construction of oxygen vacancies in δ-MnO<sub>2</sub> for promoting low-temperature toluene oxidation`,
expected: `Construction of oxygen vacancies in δ-MnO<sub>2</sub> for promoting low-temperature toluene oxidation`,
},
{
name: "单词中非首字母存在大写的保持原有大写",
original: `Accelerating VASP Electronic Structure Calculations Using Graphic Processing Units`,
expected: `Accelerating VASP electronic structure calculations using graphic processing units`,
},
{
name: "化学元素后跟逗号",
original: `Taming the redox property of A<sub>0.5</sub>Co<sub>2.5</sub>O<sub>4</sub> (a = Mg, Ca, Sr, Ba) toward high catalytic activity for N<sub>2</sub>O decomposition`,
expected: `Taming the redox property of A<sub>0.5</sub>Co<sub>2.5</sub>O<sub>4</sub> (a = Mg, Ca, Sr, Ba) toward high catalytic activity for N<sub>2</sub>O decomposition`,
},
{
name: "化学元素加括号",
original: `(N<sub>2</sub>O)`,
expected: `(N<sub>2</sub>O)`,
},
{
name: "月份应大写",
original: `Attribution of the August 2022 Extreme Heatwave in Southern China: Role of Dynamical and Thermodynamical Processes`,
expected: `Attribution of the August 2022 extreme heatwave in southern China: role of dynamical and thermodynamical processes`,
},
{
name: "月份应大写:五月例外",
original: `We'll Meet in May.`,
expected: `We'll meet in May.`,
},
{
name: "国名应大写",
original: `This is in Southern China`,
expected: `This is in southern China`,
},
{
// https://github.com/northword/zotero-format-metadata/issues/227
name: "国名应大写",
original: `A shrubby resprouting pine with serotinous cones endemic to southwest China`,
expected: `A shrubby resprouting pine with serotinous cones endemic to southwest China`,
},
];
testItems.forEach((testItem, index) => {
test(testItem.name, () => {
expect(toSentenceCase(testItem.original)).toBe(testItem.expected);
});
});