소스 검색

test: document return value when item was not found (#1779)

Andreas Möller 5 년 전
부모
커밋
1188bb81e6
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      test/unit/util.spec.js

+ 6 - 1
test/unit/util.spec.js

@@ -1,11 +1,16 @@
 import { find, deepCopy, forEachValue, isObject, isPromise, assert } from '@/util'
 
 describe('util', () => {
-  it('find', () => {
+  it('find: returns item when it was found', () => {
     const list = [33, 22, 112, 222, 43]
     expect(find(list, function (a) { return a % 2 === 0 })).toEqual(22)
   })
 
+  it('find: returns undefined when item was not found', () => {
+    const list = [1, 2, 3]
+    expect(find(list, function (a) { return a === 9000 })).toEqual(undefined)
+  })
+
   it('deepCopy: normal structure', () => {
     const original = {
       a: 1,