my-idlers/node_modules/ext/test/object/clear.js
cp6 fd22b0bf58 V2 (Laravel re-make)
V2 (Laravel re-make)
2022-03-06 02:02:12 +11:00

27 lines
778 B
JavaScript
Vendored

"use strict";
var assert = require("chai").assert
, clear = require("../../object/clear");
describe("object/clear", function () {
it("Should clear enumerable properties", function () {
var obj = { foo: "bar", elo: "sfds" };
clear(obj);
// eslint-disable-next-line no-unreachable-loop
for (var key in obj) throw new Error("Unexpected" + key);
});
it("Should return input object", function () {
var obj = {};
assert.equal(clear(obj), obj);
});
if (Object.defineProperty && Object.keys) {
it("Should keep non enumerable properties", function () {
var obj = { foo: "bar", elo: "sfds" };
Object.defineProperty(obj, "hidden", { value: "some" });
clear(obj);
assert.deepEqual(Object.keys(obj), []);
assert.equal(obj.hidden, "some");
});
}
});