Skip to content

Commit

Permalink
Chore: (test) test for default decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed Oct 31, 2019
1 parent 96ab73a commit d775eb1
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion tests/package/configurations.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs';
import { assert } from 'chai';
import { Decorator } from '../entry';
import log, { Decorator, sanitizeRegexp } from '../entry';
import { verifyConsoleStdout } from '../utils';

suite('Configurations');
Expand All @@ -10,6 +11,40 @@ function sum(a, b) {
return a + b;
}

test('Import regexp sanitizer', function () {
const obj = {
a : 'abc',
b : 123,
f : async () => {},
s : fs.createReadStream('./configurations.test.js')
};

obj.circular = obj;
assert.exists(sanitizeRegexp(obj));
assert.deepEqual(sanitizeRegexp(obj, { regexp: 'ab' }), { a: 'abc', b: 123, circular: '[Circular]' });
});

test('Default logger', function () {
const decorated = log()(
function (a) {
return a + 1;
}
);

const expected = [
/level.*:.*'info'/,
/params.*:.*'\[ 5 \]'/,
/result.*:.*'6'/,
/benchmark.*:.*'\d+\.\d+'/
];

verifyConsoleStdout(() => {
const res = decorated(5);

assert.equal(res, 6);
}, expected, { regexp: true });
});

test('Default configuration for functions', function () {
const decorator = new Decorator();
const decorated = decorator()(
Expand Down

0 comments on commit d775eb1

Please sign in to comment.