From dd4aea9b5333f5ee03fe1cee206aabce8b156c6d Mon Sep 17 00:00:00 2001 From: "kexin.xu" Date: Wed, 17 Aug 2022 18:01:29 +0800 Subject: [PATCH 1/4] exercise1 --- test/test.spec.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/test.spec.js b/test/test.spec.js index 3417042..19121e5 100644 --- a/test/test.spec.js +++ b/test/test.spec.js @@ -3,7 +3,7 @@ var assert = require('assert') describe('Array', function() { describe('#indexOf()', function() { test('当value不在数组中应当返回-1', function() { - assert.equal(-1, [1, 2, 3]/* 填空题 */) + assert.equal(-1, [1, 2, 3].indexOf(4)) }) }) }) @@ -21,14 +21,19 @@ describe('assert', function () { } } // 修改下面代码使得满足测试描述 - assert.equal(a, b) + assert.deepEqual(a, b) }) test('可以捕获并验证函数fn的错误', function () { function fn() { - xxx; + throw new Error("Wrong value"); } - // 修改下面代码使得满足测试描述 - fn() + // 修改下面代码使得满足测试描述 + + assert.throws( + fn, + Error, + '不符合预期的错误类型' + ) }) }) \ No newline at end of file From c5bb2632ce19ea5ceaceb01720c761ea75c72aac Mon Sep 17 00:00:00 2001 From: kexinxu <1760209720@qq.com> Date: Wed, 17 Aug 2022 18:11:54 +0800 Subject: [PATCH 2/4] exercise1 --- test.spec.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test.spec.js diff --git a/test.spec.js b/test.spec.js new file mode 100644 index 0000000..19121e5 --- /dev/null +++ b/test.spec.js @@ -0,0 +1,39 @@ +var assert = require('assert') + +describe('Array', function() { + describe('#indexOf()', function() { + test('当value不在数组中应当返回-1', function() { + assert.equal(-1, [1, 2, 3].indexOf(4)) + }) + }) +}) + +describe('assert', function () { + test('a和b应当深度相等', function () { + var a = { + c: { + e: 1 + } + } + var b = { + c: { + e: 1 + } + } + // 修改下面代码使得满足测试描述 + assert.deepEqual(a, b) + }) + + test('可以捕获并验证函数fn的错误', function () { + function fn() { + throw new Error("Wrong value"); + } + // 修改下面代码使得满足测试描述 + + assert.throws( + fn, + Error, + '不符合预期的错误类型' + ) + }) +}) \ No newline at end of file From 0df09861872af2cf745bab70906ff6875b6b1eaa Mon Sep 17 00:00:00 2001 From: "kexin.xu" Date: Wed, 17 Aug 2022 18:31:53 +0800 Subject: [PATCH 3/4] exercise1 --- test/test.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.spec.js b/test/test.spec.js index 19121e5..5ebdaaf 100644 --- a/test/test.spec.js +++ b/test/test.spec.js @@ -26,7 +26,7 @@ describe('assert', function () { test('可以捕获并验证函数fn的错误', function () { function fn() { - throw new Error("Wrong value"); + xxx } // 修改下面代码使得满足测试描述 From b9c4dace41108e581882949436ac9ab13ba74bc4 Mon Sep 17 00:00:00 2001 From: kexinxu <1760209720@qq.com> Date: Wed, 17 Aug 2022 18:36:01 +0800 Subject: [PATCH 4/4] exercise --- test.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.spec.js b/test.spec.js index 19121e5..5ebdaaf 100644 --- a/test.spec.js +++ b/test.spec.js @@ -26,7 +26,7 @@ describe('assert', function () { test('可以捕获并验证函数fn的错误', function () { function fn() { - throw new Error("Wrong value"); + xxx } // 修改下面代码使得满足测试描述