mirror of https://github.com/vitalif/phantomjs
Added "touch(path)" to the FS API
* Implemented in the JS Shim * Added test accordingly1.3
parent
750e1e98c4
commit
f83b9a5ba7
|
@ -98,8 +98,7 @@ public slots:
|
|||
// 'copy(source, destination)' implemented in "fs-shim.js" using '_copy(source, destination)'
|
||||
bool _copy(const QString &source, const QString &destination) const;
|
||||
// 'move(source, destination)' implemented in "fs-shim.js"
|
||||
// - touch(path, date)
|
||||
// - rename()
|
||||
// 'touch(path)' implemented in "fs-shim.js"
|
||||
|
||||
// Listing
|
||||
QStringList list(const QString &path) const;
|
||||
|
|
|
@ -144,4 +144,8 @@ window.fs.removeTree = function (path) {
|
|||
if (!fs._removeTree(path)) {
|
||||
throw "Unable to remove directory tree '" + path + "'";
|
||||
}
|
||||
};
|
||||
|
||||
window.fs.touch = function (path) {
|
||||
fs.write(path, "", 'a');
|
||||
};
|
|
@ -2,6 +2,7 @@ describe("Basic Files API (read, write, remove, ...)", function() {
|
|||
var FILENAME = "temp-01.test",
|
||||
FILENAME_COPY = FILENAME + ".copy",
|
||||
FILENAME_MOVED = FILENAME + ".moved",
|
||||
FILENAME_EMPTY = FILENAME + ".empty",
|
||||
ABSENT = "absent-01.test";
|
||||
|
||||
it("should be able to create and write a file", function() {
|
||||
|
@ -15,6 +16,13 @@ describe("Basic Files API (read, write, remove, ...)", function() {
|
|||
} catch (e) { }
|
||||
expect(fs.exists(FILENAME)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should be able to create (touch) an empty file", function() {
|
||||
expect(fs.exists(FILENAME_EMPTY)).toBeFalsy();
|
||||
fs.touch(FILENAME_EMPTY);
|
||||
expect(fs.exists(FILENAME_EMPTY)).toBeTruthy();
|
||||
expect(fs.size(FILENAME_EMPTY)).toEqual(0);
|
||||
});
|
||||
|
||||
it("should be able to read content from a file", function() {
|
||||
var content = "";
|
||||
|
@ -55,6 +63,12 @@ describe("Basic Files API (read, write, remove, ...)", function() {
|
|||
expect(fs.exists(FILENAME_COPY)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should be able to remove an empty file", function() {
|
||||
expect(fs.exists(FILENAME_EMPTY)).toBeTruthy();
|
||||
fs.remove(FILENAME_EMPTY);
|
||||
expect(fs.exists(FILENAME_EMPTY)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should throw an exception when trying to open for read a non existing file", function(){
|
||||
expect(function(){
|
||||
fs.open(ABSENT, "r");
|
||||
|
|
|
@ -6,7 +6,7 @@ describe("Attributes Files API", function() {
|
|||
|
||||
it("should throw an exception when trying to read the size of a non existing file", function(){
|
||||
expect(function(){
|
||||
fs.size(ABSENT, "r");
|
||||
fs.size(ABSENT);
|
||||
}).toThrow("Unable to read file '"+ ABSENT +"' size");
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue