forked from mystiq/hydrogen-web
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);
|
||||||
if (item.e?.stack) {
|
logPersister._queuedItems = [];
|
||||||
item.e.stack = item.e.stack.replace(/(?<=\/\?loginToken=).+/, "<snip>");
|
logPersister.options = {
|
||||||
|
serializedTransformer: (item) => {
|
||||||
|
if (item.e?.stack) {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue