Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Correct typo carset -> charset

Add specs
  • Loading branch information...
commit 278ae7c6d719cb2e5f25ea5469bf710e158b76ed 1 parent cc05072
@Stuk Stuk authored
View
6 fs-common.js
@@ -29,7 +29,7 @@ exports.update = function (exports, workingDirectory) {
} else {
options = options || {};
options.flags = flags;
- options.carset = charset;
+ options.charset = charset;
}
options.flags = "r" + (options.flags || "").replace(/r/g, "");
return Q.when(this.open(path, options), function (stream) {
@@ -57,7 +57,7 @@ exports.update = function (exports, workingDirectory) {
} else {
options = options || {};
options.flags = flags;
- options.carset = charset;
+ options.charset = charset;
}
flags = "w" + (options.flags || "").replace(/[wb]/g, "");
if (content instanceof Buffer) {
@@ -78,7 +78,7 @@ exports.update = function (exports, workingDirectory) {
} else {
options = options || {};
options.flags = flags;
- options.carset = charset;
+ options.charset = charset;
}
flags = "w+" + (options.flags || "").replace(/[w\+]/g, "");
if (content instanceof Buffer) {
View
41 spec/fs/mock/append-spec.js
@@ -0,0 +1,41 @@
+"use strict";
+
+require("../../lib/jasmine-promise");
+var Q = require("q");
+var FS = require("../../../fs");
+/*global describe,it,expect */
+
+describe("append", function () {
+
+ it("appends to a file on a mock filesystem", function () {
+ return FS.mock(FS.join(__dirname, "fixture"))
+ .then(function (mock) {
+ return Q.fcall(function () {
+ return mock.append("hello.txt", "Goodbye!\n");
+ })
+ .then(function () {
+ return mock.read("hello.txt");
+ })
+ .then(function (contents) {
+ expect(contents).toBe("Hello, World!\nGoodbye!\n");
+ });
+ });
+ });
+
+ it("calls open correctly", function () {
+ return FS.mock(FS.join(__dirname, "fixture"))
+ .then(function (mock) {
+ mock.open = function (path, options) {
+ expect(path).toBe("hello.txt");
+ expect(options.flags).toBe("w+a");
+ expect(options.charset).toBe("utf8");
+
+ return Q.resolve({write: function () {}, close: function () {}});
+ };
+
+ return mock.append("hello.txt", "Goodbye!\n", "a", "utf8");
+ });
+ });
+
+});
+
View
17 spec/fs/mock/read-spec.js
@@ -3,6 +3,7 @@
require("../../lib/jasmine-promise");
var Q = require("q");
var FS = require("../../../fs");
+/*global describe,it,expect */
describe("read", function () {
it("should read a file from a mock filesystem", function () {
@@ -19,5 +20,21 @@ describe("read", function () {
});
});
+
+ it("calls open correctly", function () {
+ return FS.mock(FS.join(__dirname, "fixture"))
+ .then(function (mock) {
+ mock.open = function (path, options) {
+ expect(path).toBe("hello.txt");
+ expect(options.flags).toBe("ra");
+ expect(options.charset).toBe("utf8");
+
+ return Q.resolve({read: function () {}, close: function () {}});
+ };
+
+ return mock.read("hello.txt", "a", "utf8");
+ });
+ });
+
});
View
14 spec/fs/mock/write-spec.js
@@ -51,5 +51,19 @@ describe("write", function () {
});
});
});
+
+ it("calls open correctly", function () {
+ return FS.mock(FS.join(__dirname, "fixture"))
+ .then(function (mock) {
+ mock.open = function (path, options) {
+ expect(path).toBe("hello.txt");
+ expect(options.flags).toBe("wa");
+ expect(options.charset).toBe("utf8");
+ return Q.resolve({write: function () {}, close: function () {}});
+ };
+
+ return mock.write("hello.txt", "Goodbye!\n", "a", "utf8");
+ });
+ });
});
Please sign in to comment.
Something went wrong with that request. Please try again.