-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typeorm): add typeorm and test bed
- Loading branch information
1 parent
1112cec
commit 090d0c4
Showing
25 changed files
with
2,538 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
import { | ||
equal, | ||
equalStrictly, | ||
gt, | ||
gtStrictly, | ||
gte, | ||
gteStrictly, | ||
isFinite, | ||
isFiniteStrictly, | ||
isNaN, | ||
isNegative, | ||
isNegativeStrictly, | ||
isPositive, | ||
isPositiveStrictly, | ||
isZero, | ||
isZeroStrictly, | ||
lt, | ||
ltStrictly, | ||
lte, | ||
lteStrictly, | ||
} from './condition'; | ||
|
||
describe('BigNumber Util Condition Functions', () => { | ||
describe('equal', () => { | ||
it('should handle value as expected', () => { | ||
expect(equal(1, 1)).toBe(1 === 1); | ||
}); | ||
it('should return false whenever non numeric value', () => { | ||
expect(equal(NaN, NaN)).toBe(false); | ||
expect(equal(<any>null, 1)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('gt', () => { | ||
it('should handle value as expected', () => { | ||
expect(gt(2, 1)).toBe(2 > 1); | ||
}); | ||
it('should return false whenever non numeric value', () => { | ||
expect(gt(<any>null, 1)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('lt', () => { | ||
it('should handle value as expected', () => { | ||
expect(lt(1, 2)).toBe(1 < 2); | ||
}); | ||
it('should return false whenever non numeric value', () => { | ||
expect(lt(<any>null, 1)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('gte', () => { | ||
it('should handle value as expected', () => { | ||
expect(gte(2, 1)).toBe(2 > 1); | ||
}); | ||
it('should return false whenever non numeric value', () => { | ||
expect(gte(<any>null, 1)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('lte', () => { | ||
it('should handle value as expected', () => { | ||
expect(lte(1, 2)).toBe(1 < 2); | ||
}); | ||
it('should return false whenever non numeric value', () => { | ||
expect(lte(<any>null, 1)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('isPositive', () => { | ||
it('should handle value as expected', () => { | ||
expect(isPositive(1)).toBe(0 < 1); | ||
}); | ||
it('should return false whenever non numeric value', () => { | ||
expect(isPositive(<any>null)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('isNegative', () => { | ||
it('should handle value as expected', () => { | ||
expect(isNegative(-1)).toBe(-1 < 0); | ||
}); | ||
it('should return false whenever non numeric value', () => { | ||
expect(isNegative(<any>null)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('isZero', () => { | ||
it('should handle value as expected', () => { | ||
expect(isZero(0)).toBe(0 === 0); | ||
}); | ||
it('should return false whenever non numeric value', () => { | ||
expect(isZero(<any>null)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('isFinite', () => { | ||
it('should handle value as expected', () => { | ||
expect(isFinite(1)).toBe(Number.isFinite(1)); | ||
}); | ||
it('should return false whenever non numeric value', () => { | ||
expect(isFinite(<any>null)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('isNaN', () => { | ||
it('should handle value as expected', () => { | ||
expect(isNaN(NaN)).toBe(Number.isNaN(NaN)); | ||
}); | ||
}); | ||
|
||
describe('equalStrictly', () => { | ||
it('should handle value as expected', () => { | ||
expect(equalStrictly(1, 1)).toBe(1 === 1); | ||
}); | ||
it('should throw error whenever non numeric value', () => { | ||
expect(() => equalStrictly(<any>null, 1)).toThrow(); | ||
expect(() => equalStrictly(<any>NaN, 1)).toThrow(); | ||
}); | ||
}); | ||
|
||
describe('gtStrictly', () => { | ||
it('should handle value as expected', () => { | ||
expect(gtStrictly(2, 1)).toBe(2 > 1); | ||
}); | ||
it('should throw error whenever non numeric value', () => { | ||
expect(() => gtStrictly(<any>null, 1)).toThrow(); | ||
}); | ||
}); | ||
|
||
describe('ltStrictly', () => { | ||
it('should handle value as expected', () => { | ||
expect(ltStrictly(1, 2)).toBe(1 < 2); | ||
}); | ||
it('should throw error whenever non numeric value', () => { | ||
expect(() => ltStrictly(<any>null, 1)).toThrow(); | ||
}); | ||
}); | ||
|
||
describe('gteStrictly', () => { | ||
it('should handle value as expected', () => { | ||
expect(gteStrictly(2, 1)).toBe(2 > 1); | ||
}); | ||
it('should throw error whenever non numeric value', () => { | ||
expect(() => gteStrictly(<any>null, 1)).toThrow(); | ||
}); | ||
}); | ||
|
||
describe('lteStrictly', () => { | ||
it('should handle value as expected', () => { | ||
expect(lteStrictly(1, 2)).toBe(1 < 2); | ||
}); | ||
it('should throw error whenever non numeric value', () => { | ||
expect(() => lteStrictly(<any>null, 1)).toThrow(); | ||
}); | ||
}); | ||
|
||
describe('isPositiveStrictly', () => { | ||
it('should handle value as expected', () => { | ||
expect(isPositiveStrictly(1)).toBe(0 < 1); | ||
}); | ||
it('should throw error whenever non numeric value', () => { | ||
expect(() => isPositiveStrictly(<any>null)).toThrow(); | ||
}); | ||
}); | ||
|
||
describe('isNegativeStrictly', () => { | ||
it('should handle value as expected', () => { | ||
expect(isNegativeStrictly(-1)).toBe(-1 < 0); | ||
}); | ||
it('should throw error whenever non numeric value', () => { | ||
expect(() => isNegativeStrictly(<any>null)).toThrow(); | ||
}); | ||
}); | ||
|
||
describe('isZeroStrictly', () => { | ||
it('should handle value as expected', () => { | ||
expect(isZeroStrictly(0)).toBe(0 === 0); | ||
}); | ||
it('should throw error whenever non numeric value', () => { | ||
expect(() => isZeroStrictly(<any>null)).toThrow(); | ||
}); | ||
}); | ||
|
||
describe('isFiniteStrictly', () => { | ||
it('should handle value as expected', () => { | ||
expect(isFiniteStrictly(1)).toBe(Number.isFinite(1)); | ||
}); | ||
it('should throw error whenever non numeric value', () => { | ||
expect(() => isFiniteStrictly(<any>null)).toThrow(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { BigNumber } from 'bignumber.js'; | ||
|
||
import { getBigNumber, getBigNumberStrictly } from './get-big-number'; | ||
|
||
export function equal(v1: BigNumber.Value, v2: BigNumber.Value): boolean { | ||
const a = getBigNumber(v1); | ||
const b = getBigNumber(v2); | ||
|
||
return a.isEqualTo(b); | ||
} | ||
|
||
export function gt(v1: BigNumber.Value, v2: BigNumber.Value): boolean { | ||
const a = getBigNumber(v1); | ||
const b = getBigNumber(v2); | ||
|
||
return a.gt(b); | ||
} | ||
|
||
export function lt(v1: BigNumber.Value, v2: BigNumber.Value): boolean { | ||
const a = getBigNumber(v1); | ||
const b = getBigNumber(v2); | ||
|
||
return a.lt(b); | ||
} | ||
|
||
export function gte(v1: BigNumber.Value, v2: BigNumber.Value): boolean { | ||
const a = getBigNumber(v1); | ||
const b = getBigNumber(v2); | ||
|
||
return a.gte(b); | ||
} | ||
|
||
export function lte(v1: BigNumber.Value, v2: BigNumber.Value): boolean { | ||
const a = getBigNumber(v1); | ||
const b = getBigNumber(v2); | ||
|
||
return a.lte(b); | ||
} | ||
|
||
export function isPositive(v: BigNumber.Value): boolean { | ||
const bn = getBigNumber(v); | ||
|
||
return bn.isPositive() && bn.isGreaterThan(0); | ||
} | ||
|
||
export function isNegative(v: BigNumber.Value): boolean { | ||
const bn = getBigNumber(v); | ||
|
||
return bn.isNegative() && bn.isLessThan(0); | ||
} | ||
|
||
export function isZero(v: BigNumber.Value): boolean { | ||
return getBigNumber(v).isZero(); | ||
} | ||
|
||
export function isFinite(v: BigNumber.Value): boolean { | ||
return getBigNumber(v).isFinite(); | ||
} | ||
|
||
export function isNaN(v: BigNumber.Value): boolean { | ||
return getBigNumber(v).isNaN(); | ||
} | ||
|
||
export function equalStrictly(v1: BigNumber.Value, v2: BigNumber.Value): boolean { | ||
const a = getBigNumberStrictly(v1); | ||
const b = getBigNumberStrictly(v2); | ||
|
||
return a.isEqualTo(b); | ||
} | ||
|
||
export function gtStrictly(v1: BigNumber.Value, v2: BigNumber.Value): boolean { | ||
const a = getBigNumberStrictly(v1); | ||
const b = getBigNumberStrictly(v2); | ||
|
||
return a.gt(b); | ||
} | ||
|
||
export function ltStrictly(v1: BigNumber.Value, v2: BigNumber.Value): boolean { | ||
const a = getBigNumberStrictly(v1); | ||
const b = getBigNumberStrictly(v2); | ||
|
||
return a.lt(b); | ||
} | ||
|
||
export function gteStrictly(v1: BigNumber.Value, v2: BigNumber.Value): boolean { | ||
const a = getBigNumberStrictly(v1); | ||
const b = getBigNumberStrictly(v2); | ||
|
||
return a.gte(b); | ||
} | ||
|
||
export function lteStrictly(v1: BigNumber.Value, v2: BigNumber.Value): boolean { | ||
const a = getBigNumberStrictly(v1); | ||
const b = getBigNumberStrictly(v2); | ||
|
||
return a.lte(b); | ||
} | ||
|
||
export function isPositiveStrictly(v: BigNumber.Value): boolean { | ||
const bn = getBigNumberStrictly(v); | ||
|
||
return bn.isPositive() && bn.isGreaterThan(0); | ||
} | ||
|
||
export function isNegativeStrictly(v: BigNumber.Value): boolean { | ||
const bn = getBigNumberStrictly(v); | ||
|
||
return bn.isNegative() && bn.isLessThan(0); | ||
} | ||
|
||
export function isZeroStrictly(v: BigNumber.Value): boolean { | ||
return getBigNumberStrictly(v).isZero(); | ||
} | ||
|
||
export function isFiniteStrictly(v: BigNumber.Value): boolean { | ||
return getBigNumberStrictly(v).isFinite(); | ||
} |
Oops, something went wrong.