我不知道为什么我在这里考试不及格,有人能给我一些启示吗?我也没有看到正确的文件出现在DevTools源代码中,所以我想这可能与它有关,但我不完全确定。
cleanObject.test.js
const cleanObject = object => {
for (let prop in object) {
if (
object[prop] === null ||
object[prop] === undefined ||
object[prop] === ""
) {
delete obj[prop];
}
}
};
describe("cleanObject", () => {
it("removes null, undefined, and empty string values", () => {
const dirty = {
a: "",
b: undefined,
c: null,
d: "value",
e: false
};
const clean = cleanObject(dirty);
expect(clean).to.deep.equal({
d: "value",
e: false
});
});
});cleanObject.test.js在DevTools源中的应用
/**
* Take an object and remove null, empty, or undefined values.
*
* @param {Object} object
* @returns {Object}
*/
const cleanObject = (object) => {
// complete the function
};
describe('cleanObject', () => {
it('removes null, undefined, and empty string values', () => {
const dirty = {
a: '',
b: undefined,
c: null,
d: 'value',
e: false,
};
const clean = cleanObject(dirty);
expect(clean).to.deep.equal({
d: 'value',
e: false,
});
});
});该文件似乎没有被发送到浏览器。有人能看到我在哪里出问题了吗?
https://stackoverflow.com/questions/49905828
复制相似问题