aboutsummaryrefslogtreecommitdiff
path: root/test/system.unit.js
blob: 7f45a6f9e66b2bb3ae1eb3ced3904b59c0528e78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
if (typeof module !== 'undefined') {
  var assert = require('assert');
  var sinon = require('sinon');
  var faker = require('../index');
}

describe("system.js", function () {
  describe("directoryPath()", function () {
    it("returns unix fs directory full path", function () {
      sinon.stub(faker.random, 'words').returns('24/7');
      var directoryPath = faker.system.directoryPath();
      assert.strictEqual(directoryPath.indexOf('/'), 0, 'generated directoryPath should start with /');
    
      faker.random.words.restore();
    });
  });

  describe("filePath()", function () {
    it("returns unix fs file full path", function () {
      sinon.stub(faker.random, 'words').returns('24/7');
      var filePath = faker.system.filePath();
      assert.strictEqual(filePath.indexOf('/'), 0, 'generated filePath should start with /');
    
      faker.random.words.restore();
    });
  });
    
  describe("fileName()", function () {
    it("returns filenames without system path separators", function () {
      sinon.stub(faker.random, 'words').returns('24/7');
      var fileName = faker.system.fileName();
      assert.strictEqual(fileName.indexOf('/'), -1, 'generated fileNames should not have path separators');

      faker.random.words.restore();
    });
  });

  describe("commonFileName()", function () {
    it("returns filenames without system path separators", function () {
      sinon.stub(faker.random, 'words').returns('24/7');
      var fileName = faker.system.commonFileName();
      assert.strictEqual(fileName.indexOf('/'), -1, 'generated commonFileNames should not have path separators');

      faker.random.words.restore();
    });
  });
});