aboutsummaryrefslogtreecommitdiff
path: root/test/modules
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2024-03-07 14:44:28 +0100
committerGitHub <[email protected]>2024-03-07 13:44:28 +0000
commite1dc906b53d96ac8ef50b1f7af2302204d67f687 (patch)
tree54246c6b7c41256ba09e6624a8621398dbc40832 /test/modules
parentccd7054e341de0f9016359ca64e1985110476729 (diff)
downloadfaker-e1dc906b53d96ac8ef50b1f7af2302204d67f687.tar.xz
faker-e1dc906b53d96ac8ef50b1f7af2302204d67f687.zip
test(finance): fix tests for amount (#2702)
Diffstat (limited to 'test/modules')
-rw-r--r--test/modules/finance.spec.ts37
1 files changed, 12 insertions, 25 deletions
diff --git a/test/modules/finance.spec.ts b/test/modules/finance.spec.ts
index e3ec6dd8..db60a9b3 100644
--- a/test/modules/finance.spec.ts
+++ b/test/modules/finance.spec.ts
@@ -260,13 +260,8 @@ describe('finance', () => {
expect(amount).toBeTruthy();
expect(amount).toBeTypeOf('string');
- expect(
- +amount,
- 'the amount should be greater than 0'
- ).toBeGreaterThan(0);
- expect(+amount, 'the amount should be less than 1001').toBeLessThan(
- 1001
- );
+ expect(+amount).toBeGreaterThanOrEqual(0);
+ expect(+amount).toBeLessThanOrEqual(1000);
});
it('should use the default decimal location when not passing arguments', () => {
@@ -275,13 +270,15 @@ describe('finance', () => {
amount = faker.finance.amount(100, 100, 1);
expect(amount).toBeTruthy();
- expect(amount, 'the amount should be equal 100.0').toBe('100.0');
+ expect(amount).toBe('100.0');
});
//TODO: add support for more currency and decimal options
it('should not include a currency symbol by default', () => {
const amount = faker.finance.amount();
+ expect(amount).toBeTruthy();
+ expect(amount).toBeTypeOf('string');
expect(
amount,
'The expected match should not include a currency symbol'
@@ -293,34 +290,24 @@ describe('finance', () => {
expect(amount).toBeTruthy();
expect(amount).toBeTypeOf('string');
- expect(+amount, 'the amount should be less than 0').toBeLessThan(0);
- expect(
- +amount,
- 'the amount should be greater than -201'
- ).toBeGreaterThan(-201);
+ expect(+amount).toBeLessThanOrEqual(-1);
+ expect(+amount).toBeGreaterThanOrEqual(-200);
});
it('should handle argument dec', () => {
const amount = faker.finance.amount(100, 100, 1);
expect(amount).toBeTruthy();
- expect(amount, 'the amount should be equal 100.0').toBe('100.0');
+ expect(amount).toBeTypeOf('string');
+ expect(amount).toBe('100.0');
});
it('should handle argument dec = 0', () => {
const amount = faker.finance.amount(100, 100, 0);
expect(amount).toBeTruthy();
- expect(amount, 'the amount should be equal 100').toBe('100');
- });
-
- it('should return a string', () => {
- const amount = faker.finance.amount(100, 100, 0);
-
- expect(amount).toBeTruthy();
- expect(amount, 'the amount type should be string').toBeTypeOf(
- 'string'
- );
+ expect(amount).toBeTypeOf('string');
+ expect(amount).toBe('100');
});
it.each([false, undefined])(
@@ -335,7 +322,7 @@ describe('finance', () => {
autoFormat
);
- expect(amount).toStrictEqual(number.toString());
+ expect(amount).toBe(number.toString());
}
);