From 194b590bb2e817ef3c431412eb60a2c79dc03a84 Mon Sep 17 00:00:00 2001 From: liyonglu123 <1719867125@qq.com> Date: Sat, 20 Aug 2022 20:59:15 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E6=94=B9exercise1=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test.spec.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/test.spec.js b/test/test.spec.js index 3417042..c14e75f 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(-1)/* 填空题 */) }) }) }) @@ -21,7 +21,7 @@ describe('assert', function () { } } // 修改下面代码使得满足测试描述 - assert.equal(a, b) + assert.deepEqual(a, b) }) test('可以捕获并验证函数fn的错误', function () { @@ -29,6 +29,11 @@ describe('assert', function () { xxx; } // 修改下面代码使得满足测试描述 - fn() + assert.throws(()=> { + throw new ReferenceError(fn()) + }, { + name: "ReferenceError", + message: "xxx is not defined" + }) }) }) \ No newline at end of file