Skip to content

Instantly share code, notes, and snippets.

@wlsf82
Last active October 26, 2017 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wlsf82/1df3411cfc812e5f5c17c6b45b6d31a5 to your computer and use it in GitHub Desktop.
Save wlsf82/1df3411cfc812e5f5c17c6b45b6d31a5 to your computer and use it in GitHub Desktop.
// sayHi.js
const sayHi = (name) => (typeof name !== "string" || name === "" || name === " ") ? "Hi!" : "Hi, " + name + "!"
// sayHi.spec.js
let assert = require("chai").assert;
describe("chai tests for sayHi function", () => {
it("should say hi to Chai", () => assert.equal(sayHi("Chai"), "Hi, Chai!"));
it("should say hi to Walmyr", () => assert.equal(sayHi("Walmyr"), "Hi, Walmyr!"));
it("should say hi to '321'", () => assert.equal(sayHi("321"), "Hi, 321!"));
it("should handle empty string input", () => assert.equal(sayHi(""), "Hi!"));
it("should handle no input", () => assert.equal(sayHi(), "Hi!"));
it("should handle number input", () => assert.equal(sayHi(1), "Hi!"));
it("should handle true boolean input", () => assert.equal(sayHi(true), "Hi!"));
it("should handle false boolean input", () => assert.equal(sayHi(false), "Hi!"));
it("should handle null input", () => assert.equal(sayHi(null), "Hi!"));
it("should handle ' ' input", () => assert.equal(sayHi(" "), "Hi!"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment