Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge branch '0.2.1' into 122_maximum_amount_invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
karmacoma authored Apr 24, 2017
2 parents fc5294d + f6b03d2 commit f3747fb
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 23 deletions.
15 changes: 0 additions & 15 deletions .githooks/post-merge/install.sh

This file was deleted.

5 changes: 0 additions & 5 deletions .githooks/pre-commit/test.sh

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/services/lsk.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ BigNumber.config({ ERRORS: false });

app.factory('lsk', () => ({
normalize(value) {
return new BigNumber(value || 0).dividedBy(Math.pow(10, 8)).toString();
return new BigNumber(value || 0).dividedBy(new BigNumber(10).pow(8)).toFixed();
},
from(value) {
return parseInt(value * Math.pow(10, 8), 10);
return new BigNumber(value * new BigNumber(10).pow(8)).round(0).toNumber();
},
}));
1 change: 0 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"exports-loader": "=0.6.3",
"extract-text-webpack-plugin": "=1.0.1",
"file-loader": "=0.9.0",
"git-hooks": "=1.1.8",
"grunt": "=1.0.1",
"grunt-eslint": "=19.0.0",
"grunt-newer": "^1.2.0",
Expand Down
58 changes: 58 additions & 0 deletions src/test/services/lsk.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const chai = require('chai');

const expect = chai.expect;

describe('Factory: lsk', () => {
let lsk;

beforeEach(angular.mock.module('app'));

beforeEach(inject((_lsk_) => {
lsk = _lsk_;
}));

describe('normalize(value)', () => {
it('converts 1 to \'0.00000001\'', () => {
expect(lsk.normalize(1)).to.equal('0.00000001');
});
});

describe('from(value)', () => {
it('converts 0.00000001 to 1', () => {
expect(lsk.from(0.00000001)).to.equal(1);
});

it('converts 1 to 100000000', () => {
expect(lsk.from(1)).to.equal(100000000);
});

it('converts 10535.67379498 to 1053567379498', () => {
expect(lsk.from(10535.67379498)).to.equal(1053567379498);
});
});

describe('normalize(from(value))', () => {
it('is identity function on 1', () => {
const value = '1';
expect(lsk.normalize(lsk.from(value))).to.equal(value);
});

it('is identity function on 10535.67379498', () => {
const value = '10535.67379498';
expect(lsk.normalize(lsk.from(value))).to.equal(value);
});
});

describe('from(normalize(value))', () => {
it('is identity function on 100000000', () => {
const value = 100000000;
expect(lsk.from(lsk.normalize(value))).to.equal(value);
});

it('is identity function on 1053567379498', () => {
const value = 1053567379498;
expect(lsk.from(lsk.normalize(value))).to.equal(value);
});
});
});

1 change: 1 addition & 0 deletions src/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ require('./components/timestamp/timestamp.spec');
require('./components/transactions/transactions.spec');

require('./services/peers/peers.spec');
require('./services/lsk.spec');

require('./util/animateOnChange/animateOnChange.spec');

0 comments on commit f3747fb

Please sign in to comment.