Skip to content

Commit

Permalink
test(animal): unroll animal test loop (#3198)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmayer authored Oct 26, 2024
1 parent 975098d commit d57899f
Showing 1 changed file with 119 additions and 23 deletions.
142 changes: 119 additions & 23 deletions test/modules/animal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,132 @@ import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;

const functionNames = [
'bear',
'bird',
'cat',
'cetacean',
'cow',
'crocodilia',
'dog',
'fish',
'horse',
'insect',
'lion',
'rabbit',
'rodent',
'snake',
'type',
] as const;

describe('animal', () => {
seededTests(faker, 'animal', (t) => {
t.itEach(...functionNames);
t.itEach(
'bear',
'bird',
'cat',
'cetacean',
'cow',
'crocodilia',
'dog',
'fish',
'horse',
'insect',
'lion',
'rabbit',
'rodent',
'snake',
'type'
);
});

describe.each(times(NON_SEEDED_BASED_RUN).map(() => faker.seed()))(
'random seeded tests for seed %i',
() => {
describe.each(functionNames)('%s()', (functionName) => {
it(`should return random value from ${functionName} array`, () => {
const actual = faker.animal[functionName]();
expect(faker.definitions.animal[functionName]).toContain(actual);
describe('bear()', () => {
it('should return random value from bear array', () => {
const actual = faker.animal.bear();
expect(faker.definitions.animal.bear).toContain(actual);
});
});

describe('bird()', () => {
it('should return random value from bird array', () => {
const actual = faker.animal.bird();
expect(faker.definitions.animal.bird).toContain(actual);
});
});

describe('cat()', () => {
it('should return random value from cat array', () => {
const actual = faker.animal.cat();
expect(faker.definitions.animal.cat).toContain(actual);
});
});

describe('cetacean()', () => {
it('should return random value from cetacean array', () => {
const actual = faker.animal.cetacean();
expect(faker.definitions.animal.cetacean).toContain(actual);
});
});

describe('cow()', () => {
it('should return random value from cow array', () => {
const actual = faker.animal.cow();
expect(faker.definitions.animal.cow).toContain(actual);
});
});

describe('crocodilia()', () => {
it('should return random value from crocodilia array', () => {
const actual = faker.animal.crocodilia();
expect(faker.definitions.animal.crocodilia).toContain(actual);
});
});

describe('dog()', () => {
it('should return random value from dog array', () => {
const actual = faker.animal.dog();
expect(faker.definitions.animal.dog).toContain(actual);
});
});

describe('fish()', () => {
it('should return random value from fish array', () => {
const actual = faker.animal.fish();
expect(faker.definitions.animal.fish).toContain(actual);
});
});

describe('horse()', () => {
it('should return random value from horse array', () => {
const actual = faker.animal.horse();
expect(faker.definitions.animal.horse).toContain(actual);
});
});

describe('insect()', () => {
it('should return random value from insect array', () => {
const actual = faker.animal.insect();
expect(faker.definitions.animal.insect).toContain(actual);
});
});

describe('lion()', () => {
it('should return random value from lion array', () => {
const actual = faker.animal.lion();
expect(faker.definitions.animal.lion).toContain(actual);
});
});

describe('rabbit()', () => {
it('should return random value from rabbit array', () => {
const actual = faker.animal.rabbit();
expect(faker.definitions.animal.rabbit).toContain(actual);
});
});

describe('rodent()', () => {
it('should return random value from rodent array', () => {
const actual = faker.animal.rodent();
expect(faker.definitions.animal.rodent).toContain(actual);
});
});

describe('snake()', () => {
it('should return random value from snake array', () => {
const actual = faker.animal.snake();
expect(faker.definitions.animal.snake).toContain(actual);
});
});

describe('type()', () => {
it('should return random value from type array', () => {
const actual = faker.animal.type();
expect(faker.definitions.animal.type).toContain(actual);
});
});
}
Expand Down

0 comments on commit d57899f

Please sign in to comment.