Skip to content

Commit 8b78826

Browse files
committed
chore: rename random helper -> faker-random
1 parent a4dcf6f commit 8b78826

File tree

11 files changed

+40
-27
lines changed

11 files changed

+40
-27
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
### 0.4.1
4+
5+
#### Changes
6+
7+
- Renamed `random` helper to `faker-random`, to avoid clash with `ember-math-helpers`
8+
39
### 0.4.0
410

511
This release includes a `random` helper for accessing the `faker` random utilities.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ ember install ember-fakerjs
3030
The list of helpers available are:
3131

3232
- `faker-fake` use this to generate content by directly using the `faker` API
33-
- `random` utility that provides parameterized access to the `random` subsection of the `faker` API
33+
- `faker-random` utility that provides parameterized access to the `random` subsection of the `faker` API
3434
- `faker-text`, `faker-sentence`, `faker-sentences` - generate lorem content
3535

3636
Example usage:
3737

3838
```hbs
39-
{{random "number" max=100}}
40-
{{random "arrayelement" array("Link" "Ganon" "Zelda")}}
39+
{{faker-random "number" max=100}}
40+
{{faker-random "arrayelement" array("Link" "Ganon" "Zelda")}}
4141
{{faker-sentence 10}} {{!-- create a 10-word sentence --}}
4242
{{faker-sentences 5}} {{!-- create a 5-sentence string --}}
4343
<img src={{faker-fake "{{image.avatar}}"}} alt="avatar">

addon/helpers/random.js addon/helpers/faker-random.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { helper } from '@ember/component/helper';
22
import faker from 'faker';
33

4-
export default helper(function random(params, hash) {
4+
export default helper(function fakerRandom(params, hash) {
55
const method = params.length > 0 ? params[0].toLowerCase() : undefined;
66
const options = { ...(hash ?? {}) };
77
switch (method) {

app/helpers/faker-random.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from 'ember-fakerjs/helpers/faker-random';

app/helpers/random.js

-1
This file was deleted.

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-fakerjs",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "Faker.js template helpers for Ember.",
55
"keywords": [
66
"ember-addon",

tests/dummy/app/styles/app.css

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4+
5+
html,
6+
body {
7+
height: 100%;
8+
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{page-title "ember-fakerjs Demo"}}
22

3-
<main class="bg-indigo-400 h-full w-full flex flex-col">
3+
<main class="bg-indigo-500 h-full w-full flex flex-col space-y-4 py-2 px-8">
44
{{outlet}}
55
</main>

tests/dummy/app/templates/index.hbs

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
<section class="bg-white p-3 m-4 flex flex-col">
1+
<section class="bg-white px-3 flex flex-col rounded-md">
2+
<div class="text-xl font-bold pb-1">\{{faker-random "arrayElement" (array "Link" "Ganon" "Zelda")}}</div>
3+
<div>{{faker-random "arrayElement" (array "Link" "Ganon" "Zelda")}}</div>
4+
</section>
5+
<section class="bg-white p-3 flex flex-col rounded-md">
6+
<div class="text-xl font-bold pb-1">\{{faker-fake "\{{name.lastName}}, \{{name.firstName}} \{{name.suffix}}"}}</div>
7+
<div>{{faker-fake "{{name.lastName}}, {{name.firstName}} {{name.suffix}}"}}</div>
8+
</section>
9+
<section class="bg-white p-3 flex flex-col rounded-md">
10+
<div class="text-xl font-bold pb-1">\{{faker-fake "\{{hacker.phrase}}"}}</div>
11+
<div>{{faker-fake "{{hacker.phrase}}"}}</div>
12+
</section>
13+
<section class="bg-white p-3 flex flex-col rounded-md">
214
<div class="text-xl font-bold pb-1">\{{faker-sentence 10}}</div>
315
<div>{{faker-sentence 10}}</div>
416
</section>
5-
<section class="bg-white p-3 m-4 flex flex-col">
17+
<section class="bg-white p-3 flex flex-col rounded-md">
618
<div class="text-xl font-bold pb-1">\{{faker-sentences 5}}</div>
719
<div>{{faker-sentences 5}}</div>
820
</section>
9-
<section class="bg-white p-3 m-4 flex flex-col">
21+
<section class="bg-white p-3 flex flex-col rounded-md">
1022
<div class="text-xl font-bold pb-1">\{{faker-text}}</div>
1123
<div>{{faker-text}}</div>
1224
</section>
13-
<section class="bg-white p-3 m-4 flex flex-col">
14-
<div class="text-xl font-bold pb-1">\{{faker-fake "\{{name.lastName}}, \{{name.firstName}} \{{name.suffix}}"}}</div>
15-
<div>{{faker-fake "{{name.lastName}}, {{name.firstName}} {{name.suffix}}"}}</div>
16-
</section>
17-
<section class="bg-white p-3 m-4 flex flex-col">
18-
<div class="text-xl font-bold pb-1">\{{faker-fake "\{{hacker.phrase}}"}}</div>
19-
<div>{{faker-fake "{{hacker.phrase}}"}}</div>
20-
</section>
21-
22-
<section class="bg-white p-3 m-4 flex flex-col">
25+
<section class="bg-white p-3 flex flex-col rounded-md">
2326
<div class="text-xl font-bold pb-1">\{{faker-fake "\{{internet.color}}"}}</div>
2427
{{#with (faker-fake "{{internet.color}}") as |color|}}
2528
<div class="py-4 px-1" style={{html-safe (concat "background-color: " color)}}>{{color}}</div>
2629
{{/with}}
2730
</section>
28-
29-
<section class="bg-white p-3 m-4 flex flex-col">
31+
<section class="bg-white p-3 flex flex-col rounded-md">
3032
<div class="text-xl font-bold pb-1">\{{faker-fake "\{{image.cats}}"}}</div>
31-
<div><img class="w-64" src={{faker-fake "{{image.cats}}"}} alt="fake"></div>
33+
<div><img class="w-32" src={{faker-fake "{{image.cats}}"}} alt="fake"></div>
3234
</section>

tests/integration/helpers/random-test.js tests/integration/helpers/faker-random-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ module('Integration | Helper | random', function (hooks) {
2525
];
2626
for (const method of methods) {
2727
this.set('method', method);
28-
await render(hbs`{{random method}}`);
28+
await render(hbs`{{faker-random method}}`);
2929
assert.ok(this.element.textContent.trim(), 'renders content');
3030
}
3131
});
3232

3333
test('it renders specific values', async function (assert) {
34-
await render(hbs`{{random "arrayelement" (array 1 2 3)}}`);
34+
await render(hbs`{{faker-random "arrayelement" (array 1 2 3)}}`);
3535
assert.ok(/[1-3]/.test(this.element.textContent.trim()), 'arrayelement');
36-
await render(hbs`{{random "notsupported"}}`);
36+
await render(hbs`{{faker-random "notsupported"}}`);
3737
assert.notOk(this.element.textContent.trim(), 'should be empty');
3838
});
3939
});

0 commit comments

Comments
 (0)