Skip to content

Commit

Permalink
test(money): 增加测试
Browse files Browse the repository at this point in the history
  • Loading branch information
twinh committed Jul 6, 2021
1 parent d9a4a5e commit b019d35
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
27 changes: 27 additions & 0 deletions __tests__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import money from '../';

describe('money', () => {
test('add', () => {
expect(money('2.51').add('0.01').toString()).toBe('2.52');
});

test('sub', () => {
expect(money('2.52').sub('0.01').toString()).toBe('2.51');
});

test('mul', () => {
expect(money('2.52').mul('6').toString()).toBe('15.12');
});

test('div', () => {
expect(money('2.52').div('3').toString()).toBe('0.84');
});

test('manipulate object', () => {
expect(money('2.51').add(money('0.01')).toString()).toBe('2.52');
});

test('remove ending zero', () => {
expect(money('2.51').sub(money('0.01')).toString()).toBe('2.5');
});
});
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'babel-preset-miaoxing',
],
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"jest": {
"preset": "jest-preset-miaoxing"
},
"dependencies": {},
"dependencies": {
"currency.js": "^2.0.4"
},
"devDependencies": {
"@miaoxing/dev": "^7.0.1"
}
Expand Down

0 comments on commit b019d35

Please sign in to comment.