Add logjam example
This commit is contained in:
19
examples/logjam/src/log.js
Normal file
19
examples/logjam/src/log.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
export function log(...args) {
|
||||
if (import.meta.env.MODE !== 'production') {
|
||||
console.log(...args);
|
||||
}
|
||||
}
|
||||
|
||||
log.error = function error(...args) {
|
||||
if (import.meta.env.MODE !== 'production') {
|
||||
console.log(...args);
|
||||
}
|
||||
};
|
||||
|
||||
log.warn = function warn(...args) {
|
||||
if (import.meta.env.MODE !== 'production') {
|
||||
console.warn(...args);
|
||||
}
|
||||
};
|
||||
14
examples/logjam/src/log.test.js
Normal file
14
examples/logjam/src/log.test.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { expect, it, vi, beforeEach, afterEach, describe } from 'vitest';
|
||||
import { log } from './log';
|
||||
|
||||
describe.todo('logger', () => {
|
||||
it('logs to the console in development mode', () => {
|
||||
const spy = vi.spyOn(console, 'log');
|
||||
|
||||
log('Hello, world!');
|
||||
|
||||
expect(spy).toHaveBeenCalledWith('Hello, world!');
|
||||
|
||||
spy.mockRestore();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user