Browse Source

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

Andreas Möller 4 years ago
parent
commit
1188bb81e6
1 changed files with 6 additions and 1 deletions
  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,