4 ms·
it("should work with booleans", () => { expect(classNames({a:true, b: false}).to.equal("a b") }) Shouldnt this just equal "a" though? See, already a
by rckclmbr 8y ago
it("should work with booleans", () => {
expect(classNames({a:true, b: false}).to.equal("a b")
})
Shouldnt this just equal "a" though? See, already a bug in your homegrown solution!
- anonytrary 8y agoMy test would fail, and I would fix it. + 2 seconds. Actually, the next test has the same problem. 2 more seconds. I'm gonna be in trouble with my boss!
- littlecranky67 8y agoNo, your test wouldn't fail because you wrote your code already being confident it is correct and went on. The bug would surface later in your team, somebody else in your team not familiar with your code would spent hours figuring out what is wrong, will consult you about your intentions when you wrote the code etc.
- anonytrary 8y agoNo, the test would fail in this case because the code was written properly because it was a TRIVIAL 2-line function (see above). A few people in this thread have regurgitated the same reasoning you have. The problem is that your reasoning is NOT an invariant under complexity. This reasoning does not apply nearly as much to trivial utility functions such as: const isObj = o => !!o && typeof o === "object" and classNames, etc. as it does to larger, more complex code. > will consult you about your intentions when you wrote the code etc. No, no they won't. No one will consult me on what my 2-line classNames functions does. It's 2 non-obfuscated lines. These aren't undergrads in CS101.