testdouble.js icon indicating copy to clipboard operation
testdouble.js copied to clipboard

td.object(['one', 'two']) syntax creates array-like object

Open Schoonology opened this issue 7 years ago • 1 comments
trafficstars

Surprisingly, td.object({ something() {} }) and td.object(['something']) produce different results; the latter is an Array.

> td.object({ something() {} }).splice
undefined
> td.object(['something']).splice
[Function: splice]

Schoonology avatar May 16 '18 20:05 Schoonology

Huh. That seems pretty wrong. Looks like it's a side effect of the (out-of-context, odd) decision to use _.transform to create the return object when passed an array of names:

https://github.com/testdouble/testdouble.js/blob/master/src/object.js#L29-L31

searls avatar May 17 '18 13:05 searls

Stale. Closing. Please reopen if still relevant and I will look into it.

giltayar avatar Sep 16 '23 11:09 giltayar