Created
March 18, 2023 18:27
-
-
Save wirwolf/2b7e2e639d2f555013a9d3048a8474c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
describe('Helpers.Quantity', () => { | |
it('should generate quantities', () => { | |
expect(scalarToQuantity(2 / 1_000_000_000, 'n')).to.equal('2n'); | |
expect(scalarToQuantity(3 / 1_000_000, 'u')) .to.equal('3u'); | |
expect(scalarToQuantity(0.1, 'm')) .to.equal('100m'); | |
expect(scalarToQuantity(BigInt(3000), 'k')) .to.equal('3k'); | |
expect(scalarToQuantity(BigInt(3 * 1000 * 1000), 'M')) .to.equal('3M'); | |
expect(scalarToQuantity(BigInt(3 * 1000 * 1000 * 1000), 'G')) .to.equal('3G'); | |
expect(scalarToQuantity(BigInt(5 * 1000 * 1000 * 1000) * BigInt(1000), 'T')) .to.equal('5T'); | |
expect(scalarToQuantity(BigInt(3 * 1000 * 1000 * 1000) * BigInt(1000 * 1000), 'P')) .to.equal('3P'); | |
expect(scalarToQuantity(BigInt(14 * 1000 * 1000 * 1000) * BigInt(1000 * 1000 * 1000), 'E')) .to.equal('14E'); | |
expect(scalarToQuantity(0.2, '')) .to.equal('0.2'); | |
expect(scalarToQuantity(1.976, 'm')) .to.equal('1976m'); | |
expect(scalarToQuantity(1024, '')) .to.equal('1024'); | |
expect(scalarToQuantity(10000, 'e3')) .to.equal('10e3'); | |
expect(scalarToQuantity(BigInt(10240), 'Ki')) .to.equal('10Ki'); | |
expect(scalarToQuantity(BigInt(1024 * 1024 * 20), 'Mi')) .to.equal('20Mi'); | |
expect(scalarToQuantity(BigInt(1024 * 1024 * 1024 * 30), 'Gi')) .to.equal('30Gi'); | |
expect(scalarToQuantity(BigInt(1024 * 1024 * 1024 * 1024 * 40), 'Ti')) .to.equal('40Ti'); | |
expect(scalarToQuantity(BigInt(1024 * 1024 * 1024 * 1024 * 1024 * 50), 'Pi')) .to.equal('50Pi'); | |
expect(scalarToQuantity(BigInt(1024 * 1024 * 1024) * BigInt(1024 * 1024 * 1024 * 60), 'Ei')) .to.equal('60Ei'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment