Explorar o código

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

Andreas Möller %!s(int64=5) %!d(string=hai) anos
pai
achega
1188bb81e6
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  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,