forked from ariya/phantomjs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fs-spec-04.js
70 lines (57 loc) · 2.85 KB
/
fs-spec-04.js
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
describe("Tests Files API", function() {
var ABSENT_DIR = "absentdir04",
ABSENT_FILE = "absentfile04",
TEST_DIR = "testdir04",
TEST_FILE = "testfile04",
TEST_FILE_PATH = fs.join(TEST_DIR, TEST_FILE),
TEST_CONTENT = "test content",
START_CWD = null;
it("should create some temporary file and directory", function(){
fs.makeDirectory(TEST_DIR);
fs.write(TEST_FILE_PATH, TEST_CONTENT, "w");
});
it("should confirm that test file and test dir exist, while the absent ones don't", function(){
expect(fs.exists(TEST_FILE_PATH)).toBeTruthy();
expect(fs.exists(TEST_DIR)).toBeTruthy();
expect(fs.exists(ABSENT_FILE)).toBeFalsy();
expect(fs.exists(ABSENT_DIR)).toBeFalsy();
});
it("should confirm that the temporary directory is infact a directory, while the absent one doesn't", function(){
expect(fs.isDirectory(TEST_DIR)).toBeTruthy();
expect(fs.isDirectory(ABSENT_DIR)).toBeFalsy();
});
it("should confirm that the temporary file is infact a file, while the absent one doesn't", function(){
expect(fs.isFile(TEST_FILE_PATH)).toBeTruthy();
expect(fs.isFile(ABSENT_FILE)).toBeFalsy();
});
it("should confirm that a relative path is not absolute, while an absolute one is", function(){
var absPath = fs.absolute(TEST_FILE_PATH);
expect(fs.isAbsolute(TEST_FILE_PATH)).toBeFalsy();
expect(fs.isAbsolute(absPath)).toBeTruthy();
});
it("should confirm that temporary file is readable, writable and non-executable, while absent file is none of those", function(){
expect(fs.isReadable(TEST_FILE_PATH)).toBeTruthy();
expect(fs.isWritable(TEST_FILE_PATH)).toBeTruthy();
expect(fs.isExecutable(TEST_FILE_PATH)).toBeFalsy();
expect(fs.isReadable(ABSENT_FILE)).toBeFalsy();
expect(fs.isWritable(ABSENT_FILE)).toBeFalsy();
expect(fs.isExecutable(ABSENT_FILE)).toBeFalsy();
});
it("should confirm that temporary directory is readable, writable and executable, while absent dir is none of those", function(){
expect(fs.isReadable(TEST_DIR)).toBeTruthy();
expect(fs.isWritable(TEST_DIR)).toBeTruthy();
expect(fs.isExecutable(TEST_DIR)).toBeTruthy();
expect(fs.isReadable(ABSENT_DIR)).toBeFalsy();
expect(fs.isWritable(ABSENT_DIR)).toBeFalsy();
expect(fs.isExecutable(ABSENT_DIR)).toBeFalsy();
});
it("should confirm that neither temporary file/dir or absent file/dir are links", function(){
expect(fs.isLink(TEST_DIR)).toBeFalsy();
expect(fs.isLink(TEST_FILE_PATH)).toBeFalsy();
expect(fs.isLink(ABSENT_DIR)).toBeFalsy();
expect(fs.isLink(ABSENT_FILE)).toBeFalsy();
});
it("should delete the temporary directory and file", function(){
fs.removeTree(TEST_DIR);
});
});