Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Jason sanjose/file api tests #11

Merged
merged 6 commits into from
Dec 14, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ Getting started

Running Tests

Run jasmine.sh or manually run Brackets-app with the argument file://path/to/brackets/test/SpecRunner.html.
2 options for running tests:

1. Run brackets-app and click "Run Tests" from the menu (debugging and dev tools **not** supported)
1. Run jasmine.sh or manually run Brackets-app with the argument file://path/to/brackets/test/SpecRunner.html.

Adding New Tests

1. Create a new .js file under spec/
1. Write the test (see spec/SampleTest.js or Jasmine documentation)
1. Write the test (see spec/Editor-test.js or Jasmine documentation)
1. Edit SpecRunner.html and add the spec .js file in a new script tag

Known Issues
Expand Down
1 change: 1 addition & 0 deletions test/SpecRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<script type="text/javascript" src="lib/jasmine-jquery-1.3.1.js"></script>

<!-- include spec files here... -->
<script type="text/javascript" src="spec/SpecRunnerUtils.js"></script>
<script type="text/javascript" src="spec/Editor-test.js"></script>
<script type="text/javascript" src="spec/NativeFileSystem-test.js"></script>
<script type="text/javascript" src="spec/LowLevelFileIO-test.js"></script>
Expand Down
5 changes: 1 addition & 4 deletions test/spec/LowLevelFileIO-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ describe("LowLevelFileIO", function() {
});

// Get window.location and remove the initial "file://" or "http://"
var baseDir = window.location.toString().substr(7);
// Remove the name of this html file
baseDir = baseDir.substr(0, baseDir.lastIndexOf("/") + 1);
baseDir += "spec/LowLevelFileIO-test-files/";
var baseDir = SpecRunnerUtils.getTestPath("/spec/LowLevelFileIO-test-files/");

beforeEach(function() {
// Pre-test setup - set permissions on special directories
Expand Down
9 changes: 1 addition & 8 deletions test/spec/NativeFileSystem-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ describe("NativeFileSystem", 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";
this.path = path;
this.path = SpecRunnerUtils.getTestPath("/spec/NativeFileSystem-test-files");
});

it("should read a directory from disk", function() {
Expand Down
13 changes: 13 additions & 0 deletions test/spec/SpecRunnerUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var SpecRunnerUtils = {
getTestRoot: function () {
// /path/to/brackets/test/SpecRunner.html
var path = window.location.href;
path = path.substr("file://".length);
path = path.substr(0,path.lastIndexOf("/"));

return path;
},
getTestPath: function(path) {
return SpecRunnerUtils.getTestRoot() + path;
}
};