-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
82 lines (61 loc) · 2.82 KB
/
test.html
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
81
82
<!DOCTYPE html>
<html>
<head>
<title>Coding Assignment</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>This page was created for testing the api in the console</h1>
<script src="q.js"></script>
<script src="api.js"></script>
<script>
//a few tests to perform
//create test folder at root
var testFolderCreated = FileAPI.create('testFolder', FileAPI.File.TYPES.FOLDER).then(function(file){
console.log("testFolder created: ", file);
//create a test file in that test folder
var testFileCreated = FileAPI.create('testFolder/testFile', FileAPI.File.TYPES.FILE);
testFileCreated.then(function(file){
console.log("testFile created in testFolder", file);
});
var testFilesToCreateAtRoot = [
{ path: 'testFileAtRoot1', type: FileAPI.File.TYPES.FILE },
{ path: 'testFileAtRoot2', type: FileAPI.File.TYPES.FILE },
{ path: 'testFileAtRoot3', type: FileAPI.File.TYPES.FILE },
{ path: 'fileToBeDeleted', type: FileAPI.File.TYPES.FILE },
{ path: 'folderToBeDeleted', type: FileAPI.File.TYPES.FOLDER }
];
//create more files at root
var moreTestFilesCreated = FileAPI.create(testFilesToCreateAtRoot);
moreTestFilesCreated.then(function(files){
console.log("multiple files created at root: ", files)
});
FileAPI.create({ path: 'testFolder/]]]', type: FileAPI.File.TYPES.FOLDER });
//create a subfolder
var subfolderCreated = FileAPI.create({ path: 'testFolder/anotherTestFolder', type: FileAPI.File.TYPES.FOLDER });
//add files to subfolder
subfolderCreated.then(function(file){
console.log("anotherTestFolder created inside testFolder: ", file);
return FileAPI.create({ path: 'testFolder/anotherTestFolder/anotherTestFile.txt', type: FileAPI.File.TYPES.FILE }).then(function(file){
console.log("file added to subfolder of testFolder: ", file);
});
});
//move a file
var fileMoved = moreTestFilesCreated.then(function(file){
return FileAPI.move("testFileAtRoot1", "testFolder/testFileFromRoot1").then(function(file){
console.log("testFileAtRoot1 moved to testFolder: ", file);
});
});
var filesToDelete = [ 'fileToBeDeleted', 'folderToBeDeleted' ];
//delete a couple of files using array syntax
var filesDeleted = FileAPI.remove(filesToDelete).then(function(files){
console.log("files deleted: ", filesToDelete);
});
Q.all(moreTestFilesCreated, subfolderCreated, fileMoved, filesDeleted).then(function(){
console.log('listing out files:');
FileAPI.listAll();
})
});
</script>
</body>
</html>