fix unit test
This commit is contained in:
parent
cd8fac2872
commit
a2a17dbf7a
1 changed files with 11 additions and 13 deletions
|
@ -323,24 +323,22 @@ import {LogItem} from "../../logging/LogItem";
|
||||||
export function tests() {
|
export function tests() {
|
||||||
return {
|
return {
|
||||||
"loginToken should not be in logs": (assert) => {
|
"loginToken should not be in logs": (assert) => {
|
||||||
const transformer = (item) => {
|
const logPersister = Object.create(IDBLogPersister.prototype);
|
||||||
|
logPersister._queuedItems = [];
|
||||||
|
logPersister.options = {
|
||||||
|
serializedTransformer: (item) => {
|
||||||
if (item.e?.stack) {
|
if (item.e?.stack) {
|
||||||
item.e.stack = item.e.stack.replace(/(?<=\/\?loginToken=).+/, "<snip>");
|
item.e.stack = item.e.stack.replace(/(?<=\/\?loginToken=).+/, "<snip>");
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const logger = {
|
const logger = { _now() {return 5;} };
|
||||||
_queuedItems: [],
|
|
||||||
_serializedTransformer: transformer,
|
|
||||||
_now: () => {}
|
|
||||||
};
|
|
||||||
logger.persist = IDBLogger.prototype._persistItem.bind(logger);
|
|
||||||
const logItem = new LogItem("test", 1, logger);
|
const logItem = new LogItem("test", 1, logger);
|
||||||
logItem.error = new Error();
|
logItem.error = new Error();
|
||||||
logItem.error.stack = "main http://localhost:3000/src/main.js:55\n<anonymous> http://localhost:3000/?loginToken=secret:26"
|
logItem.error.stack = "main http://localhost:3000/src/main.js:55\n<anonymous> http://localhost:3000/?loginToken=secret:26"
|
||||||
logger.persist(logItem, null, false);
|
logPersister.reportItem(logItem, null, false);
|
||||||
const item = logger._queuedItems.pop();
|
const item = logPersister._queuedItems.pop();
|
||||||
console.log(item);
|
|
||||||
assert.strictEqual(item.json.search("secret"), -1);
|
assert.strictEqual(item.json.search("secret"), -1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue