-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapi.spec.js
36 lines (27 loc) · 944 Bytes
/
api.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use strict";
const myLibrary = require("../../");
const { expect } = require("chai");
describe("myLibrary() API", () => {
it("should work without any arguments", () => {
let result = myLibrary();
expect(result).to.equal("Hello, world.");
});
it("should accept a custom greeting", () => {
let result = myLibrary({ greeting: "Hi there" });
expect(result).to.equal("Hi there, world.");
});
it("should accept a custom subject", () => {
let result = myLibrary({ subject: "Michael" });
expect(result).to.equal("Hello, Michael.");
});
it("should accept a custom greeting and subject", () => {
let result = myLibrary({ greeting: "Yo", subject: "man" });
expect(result).to.equal("Yo, man.");
});
it('should not allow a greeting of "goodbye"', () => {
function sayGoodbye () {
myLibrary({ greeting: "Goodbye" });
}
expect(sayGoodbye).to.throw("Cannot say goodbye");
});
});