aboutsummaryrefslogtreecommitdiff
path: root/test/modules/book.spec.ts
blob: 4da4a410b51618ae8a72c36e963ff856b79c24e2 (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
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
75
76
77
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from '../support/seeded-runs';
import { times } from '../support/times';

const NON_SEEDED_BASED_RUN = 5;

describe('book', () => {
  seededTests(faker, 'book', (t) => {
    t.itEach('author', 'format', 'genre', 'publisher', 'series', 'title');
  });

  describe.each(times(NON_SEEDED_BASED_RUN).map(() => faker.seed()))(
    'random seeded tests for seed %i',
    () => {
      describe('author()', () => {
        it('should return an author name', () => {
          const author = faker.book.author();

          expect(author).toBeTruthy();
          expect(author).toBeTypeOf('string');
          expect(faker.definitions.book.author).toContain(author);
        });
      });

      describe('format()', () => {
        it('should return a book format', () => {
          const format = faker.book.format();

          expect(format).toBeTruthy();
          expect(format).toBeTypeOf('string');
          expect(faker.definitions.book.format).toContain(format);
        });
      });

      describe('genre()', () => {
        it('should return a genre', () => {
          const genre = faker.book.genre();

          expect(genre).toBeTruthy();
          expect(genre).toBeTypeOf('string');
          expect(faker.definitions.book.genre).toContain(genre);
        });
      });

      describe('publisher()', () => {
        it('should return a publisher', () => {
          const publisher = faker.book.publisher();

          expect(publisher).toBeTruthy();
          expect(publisher).toBeTypeOf('string');
          expect(faker.definitions.book.publisher).toContain(publisher);
        });
      });

      describe('series()', () => {
        it('should return a series', () => {
          const series = faker.book.series();

          expect(series).toBeTruthy();
          expect(series).toBeTypeOf('string');
          expect(faker.definitions.book.series).toContain(series);
        });
      });

      describe('title()', () => {
        it('should return a title', () => {
          const title = faker.book.title();

          expect(title).toBeTruthy();
          expect(title).toBeTypeOf('string');
          expect(faker.definitions.book.title).toContain(title);
        });
      });
    }
  );
});