orgnote-api 0.15.3 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { test, expect } from 'vitest';
|
|
2
|
+
import { isOrgFile, isOrgGpgFile } from '../is-org-file';
|
|
3
|
+
|
|
4
|
+
test('Should return true for org files', () => {
|
|
5
|
+
const files = [
|
|
6
|
+
'myNote.org',
|
|
7
|
+
'my_note.org',
|
|
8
|
+
'123.org',
|
|
9
|
+
'some_long_note#4123$123eqasdasd.org.gpg',
|
|
10
|
+
'some_long_note#4123$123eqasdasd.org',
|
|
11
|
+
'note with space.org',
|
|
12
|
+
'note with space.org.gpg',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
files.forEach((file) => {
|
|
16
|
+
expect(isOrgFile(file), file).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('Should not return true for non-org files', () => {
|
|
21
|
+
const files = [
|
|
22
|
+
'myNote.md',
|
|
23
|
+
'my_note.md',
|
|
24
|
+
'123.md',
|
|
25
|
+
'some_long_note#4123$123eqasdas',
|
|
26
|
+
'note.org.file',
|
|
27
|
+
'org',
|
|
28
|
+
'org.',
|
|
29
|
+
'text.gpg',
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
files.forEach((file) => {
|
|
33
|
+
expect(isOrgFile(file), file).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('Should return true for org.gpg files', () => {
|
|
38
|
+
const gpgFiles = [
|
|
39
|
+
'myNote.org.gpg',
|
|
40
|
+
'my_note.org.gpg',
|
|
41
|
+
'123.org.gpg',
|
|
42
|
+
'org.org.gpg',
|
|
43
|
+
'gp_org.org.gpg',
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
gpgFiles.forEach((file) => {
|
|
47
|
+
expect(isOrgGpgFile(file), file).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('Should not return true for not .org.gpg files', () => {
|
|
52
|
+
const notGpgFiles = [
|
|
53
|
+
'myNote.org',
|
|
54
|
+
'my_note.org',
|
|
55
|
+
'123.org',
|
|
56
|
+
'some_gpg_file.txt',
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
notGpgFiles.forEach((file) => {
|
|
60
|
+
expect(isOrgGpgFile(file), file).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
});
|
package/tools/index.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const orgFileExtenstionRegex = /\.org(\.gpg)?$/;
|
|
2
|
+
export const isOrgFile = (fileName: string): boolean =>
|
|
3
|
+
orgFileExtenstionRegex.test(fileName);
|
|
4
|
+
|
|
5
|
+
const orgGpgFileExtenstionRegex = /\.org\.gpg$/;
|
|
6
|
+
export const isOrgGpgFile = (fileName: string): boolean =>
|
|
7
|
+
orgGpgFileExtenstionRegex.test(fileName);
|