Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

fix: tests/ do not bluntly assign of console.log #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const remote_or_cache = (remote_url, local_file, description, runner) => {

// Remove comments
tests = tests.filter(test => typeof test !== 'string');

// eslint-disable-next-line no-console
console.log(`Including ${tests.length} ${description}`);

QUnit.test(description, assertInner => {
Expand All @@ -68,11 +68,13 @@ const remote_or_cache = (remote_url, local_file, description, runner) => {

fs.stat(local_file, err => {
if (err) {
// eslint-disable-next-line no-console
console.log(`Downloading ${description} from JsonLogic.com`);
download(remote_url, local_file, () => {
parse_and_iterate();
});
} else {
// eslint-disable-next-line no-console
console.log(`Using cached ${description}`);
parse_and_iterate();
}
Expand Down Expand Up @@ -134,14 +136,18 @@ QUnit.test('Bad operator', assert => {

QUnit.test('logging', assert => {
let last_console;
// eslint-disable-next-line func-names
console.log = function(logged) {
last_console = logged;
const originalConsole = console;
// eslint-disable-next-line no-global-assign
console = {
log: logged => {
last_console = logged;
},
};
assert.equal(jsonLogic.apply({ log: [1] }), 1);
assert.equal(last_console, 1);

delete console.log;
assert.equal(jsonLogic.apply({ log: 'apple' }), 'apple');
assert.equal(last_console, 'apple');
// eslint-disable-next-line no-global-assign
console = originalConsole;
});

QUnit.test('edge cases', assert => {
Expand Down