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
78
79
80
81
82
83
84
85
86
87
|
import { describe, expect, it } from 'vitest';
import { faker } from '../src';
import { seededTests } from './support/seededRuns';
const NON_SEEDED_BASED_RUN = 5;
describe('science', () => {
seededTests(faker, 'science', (t) => {
t.itEach('chemicalElement', 'unit');
});
// Create and log-back the seed for debug purposes
faker.seed(Math.ceil(Math.random() * 1_000_000_000));
describe(`random seeded tests for seed ${faker.seed()}`, () => {
for (let i = 1; i <= NON_SEEDED_BASED_RUN; i++) {
describe(`chemicalElement()`, () => {
it('should return an object', () => {
const name = faker.science.chemicalElement();
expect(name).toBeTypeOf('object');
});
it('should return a valid element name when referenced into', () => {
const name = faker.science.chemicalElement().name;
expect(name).toBeTypeOf('string');
expect(() => {
faker.definitions.science.chemicalElement.find(
(element) => element.name === name
);
}).toBeTruthy();
});
it('should return a valid element symbol when referenced into', () => {
const symbol = faker.science.chemicalElement().symbol;
expect(symbol).toBeTypeOf('string');
expect(() => {
faker.definitions.science.chemicalElement.find(
(element) => element.symbol === symbol
);
}).toBeTruthy();
});
it('should return a valid element atomic number when referenced into', () => {
const atomicNumber = faker.science.chemicalElement().atomicNumber;
expect(atomicNumber).toBeTypeOf('number');
expect(() => {
faker.definitions.science.chemicalElement.find(
(element) => element.atomicNumber === atomicNumber
);
}).toBeTruthy();
});
});
describe(`unit()`, () => {
it('should return an object', () => {
const unit = faker.science.unit();
expect(unit).toBeTypeOf('object');
});
it('should return a valid unit name when referenced into', () => {
const name = faker.science.unit().name;
expect(name).toBeTypeOf('string');
expect(() => {
faker.definitions.science.unit.find((unit) => unit.name === name);
}).toBeTruthy();
});
it('should return a valid unit symbol when referenced into', () => {
const symbol = faker.science.unit().symbol;
expect(symbol).toBeTypeOf('string');
expect(() => {
faker.definitions.science.unit.find(
(unit) => unit.symbol === symbol
);
}).toBeTruthy();
});
});
}
});
});
|