fix
This commit is contained in:
parent
2bb71aeafd
commit
6777473b75
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
/node_modules/
|
||||
/dist/
|
||||
/dist/
|
||||
/.nyc_output/
|
||||
/coverage/
|
||||
|
32
test/index.js
Normal file
32
test/index.js
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
/* eslint-disable no-magic-numbers */
|
||||
// @ts-nocheck
|
||||
'use strict';
|
||||
|
||||
const test = require ('ava');
|
||||
const util = require ('../index');
|
||||
|
||||
test ('truncate_decimal', (t) => {
|
||||
const trunc = util.truncate_decimal (1.23456, 2);
|
||||
t.is (trunc, 1.23);
|
||||
});
|
||||
|
||||
test ('try_parse_json should parse', (t) => {
|
||||
const str = '{"test":"foo"}';
|
||||
t.notThrows (() => {
|
||||
const json = util.try_parse_json (str);
|
||||
t.deepEqual (json, { test: 'foo' });
|
||||
});
|
||||
});
|
||||
|
||||
test ('try_parse_json should fail', (t) => {
|
||||
const str = '{"test":foo"}';
|
||||
t.notThrows (() => {
|
||||
const json = util.try_parse_json (str);
|
||||
t.is (json, null);
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user