diff options
| -rw-r--r-- | lib/system.js | 4 | ||||
| -rw-r--r-- | test/system.unit.js | 27 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/system.js b/lib/system.js index 60a55246..9ef713c8 100644 --- a/lib/system.js +++ b/lib/system.js @@ -19,6 +19,7 @@ function System (faker) { str = str.replace(/\,/g, '_'); str = str.replace(/\-/g, '_'); str = str.replace(/\\/g, '_'); + str = str.replace(/\//g, '_'); str = str.toLowerCase(); return str; }; @@ -36,6 +37,7 @@ function System (faker) { str = str.replace(/\,/g, '_'); str = str.replace(/\-/g, '_'); str = str.replace(/\\/g, '_'); + str = str.replace(/\//g, '_'); str = str.toLowerCase(); return str; }; @@ -155,4 +157,4 @@ function System (faker) { } -module['exports'] = System;
\ No newline at end of file +module['exports'] = System; diff --git a/test/system.unit.js b/test/system.unit.js new file mode 100644 index 00000000..1edcb8be --- /dev/null +++ b/test/system.unit.js @@ -0,0 +1,27 @@ +if (typeof module !== 'undefined') { + var assert = require('assert'); + var sinon = require('sinon'); + var faker = require('../index'); +} + +describe("system.js", function () { + describe("fileName()", function () { + it("returns filenames without system path seperators", function () { + sinon.stub(faker.random, 'words').returns('24/7'); + var fileName = faker.system.fileName(); + assert.equal(fileName.indexOf('/'), -1, 'generated fileNames should not have path seperators'); + + faker.random.words.restore(); + }); + }); + + describe("commonFileName()", function () { + it("returns filenames without system path seperators", function () { + sinon.stub(faker.random, 'words').returns('24/7'); + var fileName = faker.system.commonFileName(); + assert.equal(fileName.indexOf('/'), -1, 'generated commonFileNames should not have path seperators'); + + faker.random.words.restore(); + }); + }); +}); |
