deno.land / std@0.166.0 / node / _fs / _fs_dirent_test.ts

_fs_dirent_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
80
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.import { assert, assertEquals, assertThrows } from "../../testing/asserts.ts";import Dirent from "./_fs_dirent.ts";
class DirEntryMock implements Deno.DirEntry { name = ""; isFile = false; isDirectory = false; isSymlink = false;}
Deno.test({ name: "Directories are correctly identified", fn() { const entry: DirEntryMock = new DirEntryMock(); entry.isDirectory = true; entry.isFile = false; entry.isSymlink = false; assert(new Dirent(entry).isDirectory()); assert(!new Dirent(entry).isFile()); assert(!new Dirent(entry).isSymbolicLink()); },});
Deno.test({ name: "Files are correctly identified", fn() { const entry: DirEntryMock = new DirEntryMock(); entry.isDirectory = false; entry.isFile = true; entry.isSymlink = false; assert(!new Dirent(entry).isDirectory()); assert(new Dirent(entry).isFile()); assert(!new Dirent(entry).isSymbolicLink()); },});
Deno.test({ name: "Symlinks are correctly identified", fn() { const entry: DirEntryMock = new DirEntryMock(); entry.isDirectory = false; entry.isFile = false; entry.isSymlink = true; assert(!new Dirent(entry).isDirectory()); assert(!new Dirent(entry).isFile()); assert(new Dirent(entry).isSymbolicLink()); },});
Deno.test({ name: "File name is correct", fn() { const entry: DirEntryMock = new DirEntryMock(); entry.name = "my_file"; assertEquals(new Dirent(entry).name, "my_file"); },});
Deno.test({ name: "Socket and FIFO pipes aren't yet available", fn() { const entry: DirEntryMock = new DirEntryMock(); assertThrows( () => { new Dirent(entry).isFIFO(); }, Error, "does not yet support", ); assertThrows( () => { new Dirent(entry).isSocket(); }, Error, "does not yet support", ); },});
std

Version Info

Tagged at
a year ago