aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichał Cieślar <[email protected]>2024-10-10 17:57:27 +0200
committerGitHub <[email protected]>2024-10-10 17:57:27 +0200
commit2f93d9da383638b6d232ff8b3cae827ea4c80150 (patch)
tree4e966f3ad2382f93baa993af90e1a80b65af9052 /test
parent17606589dd58151e43c037a3acfa82046b33e37c (diff)
downloadfaker-2f93d9da383638b6d232ff8b3cae827ea4c80150.tar.xz
faker-2f93d9da383638b6d232ff8b3cae827ea4c80150.zip
feat: add book module (#2949)
Diffstat (limited to 'test')
-rw-r--r--test/modules/__snapshots__/book.spec.ts.snap37
-rw-r--r--test/modules/book.spec.ts77
2 files changed, 114 insertions, 0 deletions
diff --git a/test/modules/__snapshots__/book.spec.ts.snap b/test/modules/__snapshots__/book.spec.ts.snap
new file mode 100644
index 00000000..9a31406d
--- /dev/null
+++ b/test/modules/__snapshots__/book.spec.ts.snap
@@ -0,0 +1,37 @@
+// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
+
+exports[`book > 42 > author 1`] = `"Henry David Thoreau"`;
+
+exports[`book > 42 > format 1`] = `"Ebook"`;
+
+exports[`book > 42 > genre 1`] = `"Fantasy"`;
+
+exports[`book > 42 > publisher 1`] = `"Flame Tree Publishing"`;
+
+exports[`book > 42 > series 1`] = `"Sherlock Holmes"`;
+
+exports[`book > 42 > title 1`] = `"Lord Jim"`;
+
+exports[`book > 1211 > author 1`] = `"Virgil"`;
+
+exports[`book > 1211 > format 1`] = `"Paperback"`;
+
+exports[`book > 1211 > genre 1`] = `"Western"`;
+
+exports[`book > 1211 > publisher 1`] = `"University of Akron Press"`;
+
+exports[`book > 1211 > series 1`] = `"Thursday Next Series"`;
+
+exports[`book > 1211 > title 1`] = `"Tinker, Tailor, Soldier, Spy"`;
+
+exports[`book > 1337 > author 1`] = `"Frances Hodgson Burnett"`;
+
+exports[`book > 1337 > format 1`] = `"Ebook"`;
+
+exports[`book > 1337 > genre 1`] = `"Comic"`;
+
+exports[`book > 1337 > publisher 1`] = `"City Lights Publishers"`;
+
+exports[`book > 1337 > series 1`] = `"Jane Austen Murder Mysteries"`;
+
+exports[`book > 1337 > title 1`] = `"Gone with the Wind"`;
diff --git a/test/modules/book.spec.ts b/test/modules/book.spec.ts
new file mode 100644
index 00000000..4da4a410
--- /dev/null
+++ b/test/modules/book.spec.ts
@@ -0,0 +1,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);
+ });
+ });
+ }
+ );
+});