Last active
October 26, 2017 20:15
-
-
Save wlsf82/1df3411cfc812e5f5c17c6b45b6d31a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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