aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorShinigami <[email protected]>2022-05-02 20:17:48 +0200
committerGitHub <[email protected]>2022-05-02 20:17:48 +0200
commit42d679566624aaedd01eb5c0d9fa54104008016c (patch)
tree2e55b529042b57059a44482302b4663c7bec9bd5 /test
parent4efaff90851cc9a24a9f4d9603e8fca7660a2d29 (diff)
downloadfaker-42d679566624aaedd01eb5c0d9fa54104008016c.tar.xz
faker-42d679566624aaedd01eb5c0d9fa54104008016c.zip
fix: replace deprecated arrayElement calls (#903)
Diffstat (limited to 'test')
-rw-r--r--test/fake.spec.ts4
-rw-r--r--test/unique.spec.ts5
2 files changed, 5 insertions, 4 deletions
diff --git a/test/fake.spec.ts b/test/fake.spec.ts
index 16193cf7..2846b9ee 100644
--- a/test/fake.spec.ts
+++ b/test/fake.spec.ts
@@ -11,7 +11,7 @@ describe('fake', () => {
it('replaces multiple tokens with random values for methods with no parameters', () => {
const name = faker.fake(
- '{{random.arrayElement}}{{random.arrayElement}}{{random.arrayElement}}'
+ '{{helpers.arrayElement}}{{helpers.arrayElement}}{{helpers.arrayElement}}'
);
expect(name).toMatch(/[abc]{3}/);
});
@@ -24,7 +24,7 @@ describe('fake', () => {
it('replaces a token with a random value for a method with an array parameter', () => {
const arr = ['one', 'two', 'three'];
const random = faker.fake(
- '{{random.arrayElement(["one", "two", "three"])}}'
+ '{{helpers.arrayElement(["one", "two", "three"])}}'
);
expect(arr).toContain(random);
});
diff --git a/test/unique.spec.ts b/test/unique.spec.ts
index e304092d..909b26a4 100644
--- a/test/unique.spec.ts
+++ b/test/unique.spec.ts
@@ -37,7 +37,7 @@ const MOCK_ARRAY = Array.from(
);
function customMethod(prefix: string = ''): string {
- const element = faker.random.arrayElement(MOCK_ARRAY);
+ const element = faker.helpers.arrayElement(MOCK_ARRAY);
return `${prefix}${element}`;
}
@@ -150,7 +150,8 @@ Try adjusting maxTime or maxRetries parameters for faker.unique().`)
// This test can be only executed once, because the unique function has a global state.
// See: https://github.com/faker-js/faker/issues/371
it('should be possible to exclude results as array', () => {
- const internetProtocol = () => faker.random.arrayElement(['https', 'http']);
+ const internetProtocol = () =>
+ faker.helpers.arrayElement(['https', 'http']);
const result = faker.unique(internetProtocol, [], {
exclude: ['https'],
});