Socialify

Folder ..

Viewing system.spec.ts
74 lines (58 loc) • 1.8 KB

 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { describe, expect, it, vi } from 'vitest';
import { faker } from '../dist/cjs';

describe('system', () => {
  describe('directoryPath()', () => {
    it('returns unix fs directory full path', () => {
      const spy_random_words = vi
        .spyOn(faker.random, 'words')
        .mockReturnValue('24/7');

      const directoryPath = faker.system.directoryPath();

      expect(
        directoryPath.indexOf('/'),
        'generated directoryPath should start with /'
      ).toBe(0);

      spy_random_words.mockRestore();
    });
  });

  describe('filePath()', () => {
    it('returns unix fs file full path', () => {
      const spy_random_words = vi
        .spyOn(faker.random, 'words')
        .mockReturnValue('24/7');

      const filePath = faker.system.filePath();

      expect(
        filePath.indexOf('/'),
        'generated filePath should start with /'
      ).toBe(0);

      spy_random_words.mockRestore();
    });
  });

  describe('fileName()', () => {
    it('returns filenames without system path separators', () => {
      const spy_random_words = vi
        .spyOn(faker.random, 'words')
        .mockReturnValue('24/7');

      const fileName = faker.system.fileName();

      expect(
        fileName.indexOf('/'),
        'generated fileNames should not have path separators'
      ).toBe(-1);

      spy_random_words.mockRestore();
    });
  });

  describe('commonFileName()', () => {
    it('returns filenames without system path separators', () => {
      const spy_random_words = vi
        .spyOn(faker.random, 'words')
        .mockReturnValue('24/7');

      const fileName =
        // @ts-expect-error
        faker.system.commonFileName();

      expect(
        fileName.indexOf('/'),
        'generated commonFileNames should not have path separators'
      ).toBe(-1);

      spy_random_words.mockRestore();
    });
  });
});