working flat() polyfill for jest
This commit is contained in:
parent
54e0a48701
commit
94935b023b
|
@ -49,6 +49,9 @@
|
||||||
],
|
],
|
||||||
"setupFilesAfterEnv": [
|
"setupFilesAfterEnv": [
|
||||||
"@testing-library/jest-dom/extend-expect"
|
"@testing-library/jest-dom/extend-expect"
|
||||||
|
],
|
||||||
|
"setupFiles": [
|
||||||
|
"./scripts/jestSetup.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
if (!Array.prototype.flat) {
|
||||||
|
Object.defineProperty(Array.prototype, "flat", {
|
||||||
|
configurable: true,
|
||||||
|
value: function flat() {
|
||||||
|
var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0])
|
||||||
|
|
||||||
|
return depth
|
||||||
|
? Array.prototype.reduce.call(
|
||||||
|
this,
|
||||||
|
function(acc, cur) {
|
||||||
|
if (Array.isArray(cur)) {
|
||||||
|
acc.push.apply(acc, flat.call(cur, depth - 1))
|
||||||
|
} else {
|
||||||
|
acc.push(cur)
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
: Array.prototype.slice.call(this)
|
||||||
|
},
|
||||||
|
writable: true,
|
||||||
|
})
|
||||||
|
}
|
|
@ -1,10 +1,4 @@
|
||||||
import fetchBindableProperties from "../src/builderStore/fetchBindableProperties"
|
import fetchBindableProperties from "../src/builderStore/fetchBindableProperties"
|
||||||
import { flat } from "lodash"
|
|
||||||
|
|
||||||
// supports running jest on Node 10.x
|
|
||||||
if (!Array.flat) {
|
|
||||||
Array.flat = flat
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("fetch bindable properties", () => {
|
describe("fetch bindable properties", () => {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue