refactor(infra): directory structure (#4615)

This commit is contained in:
Joooye_34
2023-10-18 23:30:08 +08:00
committed by GitHub
parent 814d552be8
commit bed9310519
1150 changed files with 539 additions and 584 deletions
@@ -0,0 +1,34 @@
/**
* @vitest-environment happy-dom
*/
import { describe, expect, test, vi } from 'vitest';
import { DebugLogger } from '..';
describe('debug', () => {
test('disabled', () => {
const logger = new DebugLogger('test');
logger.enabled = false;
for (const level of ['debug', 'info', 'warn', 'error'] as const) {
const fn = vi.fn();
vi.spyOn(globalThis.console, level).mockImplementation(fn);
expect(logger.enabled).toBe(false);
expect(fn).not.toBeCalled();
logger[level]('test');
expect(fn, level).not.toBeCalled();
}
});
test('log', () => {
const logger = new DebugLogger('test');
logger.enabled = true;
for (const level of ['debug', 'info', 'warn', 'error'] as const) {
const fn = vi.fn();
vi.spyOn(globalThis.console, level).mockImplementation(fn);
expect(logger.enabled).toBe(true);
expect(fn).not.toBeCalled();
logger[level]('test');
expect(fn, level).toBeCalled();
}
});
});