feat: tests

This commit is contained in:
2023-04-21 12:08:35 +02:00
parent 8cb9285462
commit d8c79256c9
140 changed files with 2100 additions and 2693 deletions

View File

@@ -13,15 +13,12 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {expect} from 'chai';
import {suite, test} from '@testdeck/mocha';
import {AddLogLevel} from '../../src/transformations/add-log-level.js';
import {AddLogLevel} from '../../src/index.js';
@suite()
export class AddLogLevelSpec {
@test
transform() {
describe('add log level', function () {
it('should transform', function () {
const transformation = new AddLogLevel();
expect(transformation.transform('ERROR', 'Foobar')).to.be.equal('[ERROR] Foobar');
}
}
});
});

View File

@@ -13,18 +13,18 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {expect} from 'chai';
import {suite, test} from '@testdeck/mocha';
import {Colorize} from '../../src/transformations/colorize.js';
import {Colorize} from '../../src/index.js';
import chalk from 'chalk';
@suite()
export class ColorizeSpec {
@test
transform() {
chalk.level = 2;
describe('colorize', function () {
it('should transform', function () {
const transformation = new Colorize();
expect(transformation.transform('ERROR', 'Foobar')).to.be.equal(
'\u001b[1m\u001b[31mFoobar\u001b[39m\u001b[22m',
'\u001B[1m\u001B[31mFoobar\u001B[39m\u001B[22m',
);
expect(transformation.transform('LOG', 'Foobar')).to.be.equal('\u001b[37mFoobar\u001b[39m');
}
}
expect(transformation.transform('LOG', 'Foobar')).to.be.equal('\u001B[37mFoobar\u001B[39m');
});
});

View File

@@ -13,15 +13,12 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {expect} from 'chai';
import {suite, test} from '@testdeck/mocha';
import {Timestamp} from '../../src/transformations/timestamp.js';
import {Timestamp} from '../../src/index.js';
@suite()
export class TimeStampSpec {
@test
default() {
describe('timestamp', function () {
it('should contain Z', function () {
const transformation = new Timestamp();
expect(transformation.transform('ERROR', 'Foobar')).to.be.contain(`Z`);
}
}
});
});