1
0
mirror of https://github.com/adobe/brackets.git synced 2024-11-20 09:53:00 +01:00

Merge pull request #7 from adobe/joelrbrandt/file-api-tests

Joelrbrandt/file api tests -- reviewed by nj
This commit is contained in:
Narciso Jaramillo 2011-12-13 09:53:42 -08:00
commit 0dab0e62c5
4 changed files with 61 additions and 0 deletions

View File

@ -25,12 +25,14 @@
<!-- include spec files here... -->
<script type="text/javascript" src="spec/SampleTest.js"></script>
<script type="text/javascript" src="spec/NativeFileSystem-test.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="../src/thirdparty/CodeMirror2/lib/CodeMirror.js"></script>
<script type="text/javascript" src="../src/thirdparty/CodeMirror2/mode/javascript/javascript.js"></script>
<script type="text/javascript" src="../src/thirdparty/jquery-1.7.min.js"></script>
<script type="text/javascript" src="../src/thirdparty/less-1.1.5.min.js"></script>
<script type="text/javascript" src="../src/NativeFileSystem.js"></script>
<script type="text/javascript">
(function() {

View File

@ -0,0 +1 @@
this is file2 in dir1

View File

@ -0,0 +1 @@
Here is file1

View File

@ -0,0 +1,57 @@
describe("NativeFileSystem", function(){
describe("Reading", function() {
beforeEach(function() {
this.addMatchers({
toContainDirectoryWithName: function(expected) {
for (var i = 0 ; i < this.actual.length; ++i) {
if (this.actual[i].isDirectory && this.actual[i].name === expected) {
return true;
}
}
return false;
}
, toContainFileWithName: function(expected) {
for (var i = 0 ; i < this.actual.length; ++i) {
if (this.actual[i].isFile && this.actual[i].name === expected) {
return true;
}
}
return false;
}
});
});
it("should read a directory from disk", function() {
//TODO: Make this relative -- right now, asking for "." gives "/"
//Want to be able to simply use:
// var path = "spec/NativeFileSystem-test-files";
var path = window.location.href;
path = path.substr("file://".length);
path = path.substr(0,path.lastIndexOf("/")+1);
path = path + "spec/NativeFileSystem-test-files";
var entries = null;
var readComplete = false;
var nfs = window.NativeFileSystem.requestNativeFileSystem(path);
var reader = nfs.createReader();
var successCallback = function(e) { entries = e; readComplete = true; }
// TODO: not sure what parameters error callback will take because it's not implemented yet
var errorCallback = function() { readComplete = true; }
reader.readEntries(successCallback, errorCallback);
waitsFor(function() { return readComplete; }, 1000);
runs(function() {
expect(entries).toContainDirectoryWithName("dir1");
expect(entries).toContainFileWithName("file1");
expect(entries).not.toContainFileWithName("file2");
});
});
});
});