Skip to content

Commit

Permalink
feat: 添加一个好久好久的实现
Browse files Browse the repository at this point in the history
  • Loading branch information
ZWkang committed Sep 1, 2021
1 parent 867de89 commit fcfbe54
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 0 deletions.
31 changes: 31 additions & 0 deletions simple-easy-assert/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@



// describe('earth', function(){
// beforeEach(function(){
// console.log('see.. this function is run EACH time, before each describe()')
// })
// describe('singapre', function(){
// it('birds should fly', function(){ /** ... */ })
// })
// describe('malaysia', function(){
// it('birds should soar', function(){ /** ... */ })
// })
// })
function add(aNumber, bNumber) {
return aNumber + bNumber;
}


const 希望 = require("ctressa")

test("两个字符串相等吗", () => {
希望("test").("tests").严格相等
})

test("希望我的add函数能正常吧", () => {
希望(add(1,2)).(3).严格相等
})



15 changes: 15 additions & 0 deletions simple-easy-assert/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "simple-easy-assert",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"chalk": "^4.1.2",
"ctressa": "^1.2.0"
}
}
174 changes: 174 additions & 0 deletions simple-easy-assert/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions simple-easy-assert/running.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const chalk = require("chalk")



const testCases = []
function test(title, cb) {
testCases.push({
title,
cb
})
}

let successTotal = 0;
let failTotal = 0;

let failCase = [];

function run() {
for(const testCase of testCases) {
const { title, cb } = testCase;
try {
cb.call(this);
successTotal += 1;
}catch(e) {
failTotal += 1;
failCase.push({
reason: e.message,
actual: e.actual,
expected: e.expected,
title
})
}
}

console.log(`${chalk.green(`Total Test Total: ${successTotal + failTotal}`)}
Tests Suites: ${chalk.green(`${successTotal} total passed`)}
Tests Suites: ${chalk.red(`${failTotal} total failed`)}
`)


for(const fail of failCase) {
console.log(`
Test Case: ${fail.title}
Fail reason: ${chalk.red(`${fail.reason}`)}
${chalk.green(`expected ---=> ${fail.expected}`)}
${chalk.red(`actual ---=> ${fail.actual}`)}
`)
}
}
global.test = test;

require('./index');

run()

0 comments on commit fcfbe54

Please sign in to comment.