Skip to content

Commit

Permalink
Lotta test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
SiddharthShyniben committed Feb 13, 2022
1 parent 6ad0e89 commit 424fbd5
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import debug from '../index.js';

const a = debug('name-one');
const b = debug('longer-name');
const c = debug('sth');

function workA() {
a('doing some work here');
setTimeout(workA, Math.random() * 1000);
}

function workB() {
b('doing some more work here');
setTimeout(workB, Math.random() * 1000);
}

function workC() {
c('lots of uninteresting work here');
setTimeout(workC, Math.random() * 1000);
}

workA()
workB()
workC()
11 changes: 11 additions & 0 deletions test/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import debug from '../index.js';

const events = debug('events');

events.events.on('log', (scope, message) => {
console.log('log in', scope, 'message is', message);
});

events('Log a')
events('Log b')
events('Log c')
9 changes: 9 additions & 0 deletions test/extend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import debug from '../index.js';

const worker = debug('worker');
const workerA = worker.extend('a');
const workerB = worker.extend('b');

worker('doing some work here')
workerA('doing some a work here')
workerB('doing some b work here')
20 changes: 20 additions & 0 deletions test/extend2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import debug from './index.js';

const foo = debug('foo');
const bar = foo.extend('bar');
const baz = bar.extend('baz');

function workFoo() {
foo('working foo');

if (Math.random() > 0.5) {
bar('working bar');
if (Math.random() > 0.5) {
baz('working baz');
}
}

setTimeout(workFoo, Math.random() * 1000);
}

workFoo();
5 changes: 5 additions & 0 deletions test/long-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import debug from '../index.js';

const longString = debug('long-string');

longString('This is a long string with new lines and some more stuff which should trigger wrapping but may not.\nThe point of this test is to make sure that new lines are split so that we get cleaner output on multiple lines.');
9 changes: 9 additions & 0 deletions test/syntax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import debug from '../index.js';

const a = debug('a');

a('hello heres some code: %o', {
foo: 'bar',
baz: 'qux',
number: 1,
});
15 changes: 15 additions & 0 deletions test/time.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import debug from '../index.js';

const time = debug('time');

time.time('Starting');
setTimeout(() => {
time.markTime('Interval');
setTimeout(() => {
time.markTime('Interval and some\nnewlines\nhere\nlol');
setTimeout(() => {
time.markTime('Interval');
time.endTime('Ending');
}, 1000);
}, 1000);
}, 1000);

0 comments on commit 424fbd5

Please sign in to comment.