Last active
June 27, 2021 09:05
-
-
Save koshuang/ded88d72cb51fad37af14557d70a230f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require('lodash'); | |
const log = { | |
describe(str) { | |
console.log(`describe: ${str}`); | |
}, | |
it(str) { | |
console.log(`\t it ${str}`); | |
}, | |
assertEquals(str) { | |
console.log(`\t\tResult: ${str}`); | |
}, | |
error(str) { | |
console.log(`\t\tResult: ${str}`); | |
}, | |
}; | |
function add(a, b) { | |
return a + b; | |
} | |
test(); | |
function test() { | |
assertEquals(2, add(1, 1)); | |
} | |
function describe(description, fn) { | |
log.describe(description); | |
fn(); | |
} | |
function it(sentence, fn) { | |
log.it(sentence); | |
fn(); | |
} | |
function assertEquals(expected, actual) { | |
if (_.isEqual(expected, actual)) { | |
log.assertEquals('Passed'); | |
} else { | |
log.error(`${JSON.stringify(actual)} is not expected as ${JSON.stringify(expected)}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment