From f950bbe16419b2dd8ac9e7aceeaaf64f5adb17ef Mon Sep 17 00:00:00 2001 From: Ben Blank Date: Mon, 21 Mar 2016 09:59:18 -0700 Subject: [PATCH] add tests for _.invoke --- lodash/lodash-tests.ts | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index eb74bd0bb..425ef6dfb 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -4364,6 +4364,47 @@ namespace TestKeyBy { } } +//_.invoke +namespace TestInvoke { + let nestedDict: _.Dictionary> = { + a: [0, 1, 2] + } + let numDict: _.Dictionary = { + a: 1, + b: 2, + c: 3, + d: 4 + } + + let result: any; + result = _.invoke(numDict, "a.toString"); + result = _.invoke(numDict, "a.toString", 2); + result = _.invoke(numDict, ["a", "toString"]); + result = _.invoke(numDict, ["a", "toString"], 2); + result = _.invoke>(nestedDict, ["a[0].toString"]); + result = _.invoke>(nestedDict, ["a[0].toString"], 2); + result = _.invoke>(nestedDict, ["a", 0, "toString"]); + result = _.invoke>(nestedDict, ["a", 0, "toString"], 2); + + result = _(numDict).invoke("a.toString"); + result = _(numDict).invoke("a.toString", 2); + result = _(numDict).invoke(["a", "toString"]); + result = _(numDict).invoke(["a", "toString"], 2); + result = _(nestedDict).invoke("a[0].toString"); + result = _(nestedDict).invoke("a[0].toString", 2); + result = _(nestedDict).invoke(["a", 0, "toString"]); + result = _(nestedDict).invoke(["a", 0, "toString"], 2); + + result = _(numDict).chain().invoke("a.toString"); + result = _(numDict).chain().invoke("a.toString", 2); + result = _(numDict).chain().invoke(["a", "toString"]); + result = _(numDict).chain().invoke(["a", "toString"], 2); + result = _(nestedDict).chain().invoke("a[0].toString"); + result = _(nestedDict).chain().invoke("a[0].toString", 2); + result = _(nestedDict).chain().invoke(["a", 0, "toString"]); + result = _(nestedDict).chain().invoke(["a", 0, "toString"], 2); +} + //_.invokeMap namespace TestInvokeMap { let numArray = [4, 2, 1, 3]