Skip to content

Commit

Permalink
Age 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jan 9, 2022
1 parent 9eae81d commit ad1fc07
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<a name="2.0.0"></a>
# [2.0.0](https://github.com/faker-javascript/age) (2022-01-09)

### BREAKING CHANGES

* New function `age` istead of `fakeAge`

<a name="1.0.0"></a>
# [1.0.0](https://github.com/faker-javascript/age) (2022-01-08)
* Initial release
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ $ npm install --save @fakerjs/age
## Usage

```js
import fakeAge from '@fakerjs/age';
import age from '@fakerjs/age';

fakeAge();
age();
//=> 42

fakeAge({type: 'child'});
age({type: 'child'});
//=> 10

// Allowed type: child, teen, adult, senior
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function fakeAge(options) {
export default function age(options) {
options = options || {};
let min = 0;
let max = 100;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fakerjs/age",
"version": "1.0.0",
"version": "2.0.0",
"description": "Age package provides functionality to generate a fake age value.",
"license": "MIT",
"repository": "faker-javascript/age",
Expand All @@ -25,6 +25,7 @@
],
"keywords": [
"fakerjs",
"faker",
"fake",
"random",
"age"
Expand Down
36 changes: 18 additions & 18 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import fakeAge from './index.js';
import age from './index.js';
import test from 'ava';

test('fakeAge return type to be number', t => {
t.is(typeof fakeAge(), 'number');
test('age return type to be number', t => {
t.is(typeof age(), 'number');
});

test('fakeAge with type child less than 13 and more than -1', t => {
t.true(fakeAge({type: 'child'}) < 13);
t.true(fakeAge({type: 'child'}) > -1);
test('age with type child less than 13 and more than -1', t => {
t.true(age({type: 'child'}) < 13);
t.true(age({type: 'child'}) > -1);
});

test('fakeAge with type teen less than 20 and more than 12', t => {
t.true(fakeAge({type: 'teen'}) < 20);
t.true(fakeAge({type: 'teen'}) > 12);
test('age with type teen less than 20 and more than 12', t => {
t.true(age({type: 'teen'}) < 20);
t.true(age({type: 'teen'}) > 12);
});

test('fakeAge with type adult less than 69 and more than 17', t => {
t.true(fakeAge({type: 'adult'}) < 69);
t.true(fakeAge({type: 'adult'}) > 17);
test('age with type adult less than 69 and more than 17', t => {
t.true(age({type: 'adult'}) < 69);
t.true(age({type: 'adult'}) > 17);
});

test('fakeAge with type senior less than 101 and more than 64', t => {
t.true(fakeAge({type: 'senior'}) < 101);
t.true(fakeAge({type: 'senior'}) > 64);
test('age with type senior less than 101 and more than 64', t => {
t.true(age({type: 'senior'}) < 101);
t.true(age({type: 'senior'}) > 64);
});

test('fakeAge with type all less than 101 and more than -1', t => {
t.true(fakeAge({type: 'all'}) < 101);
t.true(fakeAge({type: 'all'}) > -1);
test('age with type all less than 101 and more than -1', t => {
t.true(age({type: 'all'}) < 101);
t.true(age({type: 'all'}) > -1);
});

0 comments on commit ad1fc07

Please sign in to comment.