Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe("Test list", () => {
- describe("Test 1 ", () => {
- it("calcPriceOfBook ", () => {
- assert.throw(() => library.calcPriceOfBook(1, 'abv'), 'Invalid input');
- assert.throw(() => library.calcPriceOfBook([], []), 'Invalid input');
- assert.throw(() => library.calcPriceOfBook(1.1, 1.1), 'Invalid input');
- assert.throw(() => library.calcPriceOfBook(' ', -1.1), 'Invalid input');
- assert.throw(() => library.calcPriceOfBook({}, {}), 'Invalid input');
- assert.throw(() => library.calcPriceOfBook(NaN, {}), 'Invalid input');
- assert.throw(() => library.calcPriceOfBook(NaN, NaN), 'Invalid input');
- assert.throw(() => library.calcPriceOfBook(1, 0), 'Invalid input');
- assert.throw(() => library.calcPriceOfBook(undefined, NaN), 'Invalid input');
- assert.throw(() => library.calcPriceOfBook([], {}), 'Invalid input');
- });
- it("calcPrice", () => {
- let price = 20;
- let total = 10;
- let nameOfBook = "Book";
- // assert.equal(library.calcPriceOfBook(nameOfBook, price), `Price of ${nameOfBook} is ${price.toFixed(2)}`);
- assert.equal(library.calcPriceOfBook(nameOfBook, 1981), `Price of ${nameOfBook} is ${price.toFixed(2)}`);
- assert.equal(library.calcPriceOfBook(nameOfBook, 1979), `Price of ${nameOfBook} is ${total.toFixed(2)}`);
- assert.equal(library.calcPriceOfBook(nameOfBook, 1980), `Price of ${nameOfBook} is ${total.toFixed(2)}`);
- assert.equal(library.calcPriceOfBook(nameOfBook, 0), `Price of ${nameOfBook} is ${total.toFixed(2)}`);
- assert.equal(library.calcPriceOfBook(nameOfBook, -1980), `Price of ${nameOfBook} is ${total.toFixed(2)}`);
- });
- it('test findBook', () => {
- assert.throw(() => library.findBook(([])), "No books currently available");
- });
- it("test findBook 1 ", () => {
- booksArr = ["Troy", "Life Style", "Torronto"];
- desiredBook = "Troy";
- desiredBook1 = " "
- assert.equal(library.findBook(booksArr, desiredBook), "We found the book you want.")
- assert.equal(library.findBook(booksArr, desiredBook1), "The book you are looking for is not here!")
- });
- it("arrangeTheBooks", () => {
- assert.throw(() => library.arrangeTheBooks(1.1, -5), "Invalid input");
- assert.throw(() => library.arrangeTheBooks([], -5), "Invalid input");
- assert.throw(() => library.arrangeTheBooks(NaN, -5), "Invalid input");
- assert.throw(() => library.arrangeTheBooks(NaN, NaN), "Invalid input");
- assert.throw(() => library.arrangeTheBooks(1.1, 5), "Invalid input");
- assert.throw(() => library.arrangeTheBooks(1.1, undefined), "Invalid input");
- assert.throw(() => library.arrangeTheBooks(1.1, 0.2), "Invalid input");
- assert.throw(() => library.arrangeTheBooks('1.1', -5), "Invalid input");
- assert.throw(() => library.arrangeTheBooks([], []), "Invalid input");
- assert.throw(() => library.arrangeTheBooks({}, {}), "Invalid input");
- assert.throw(() => library.arrangeTheBooks([], {}), "Invalid input");
- });
- it("arrangeTheBooks", () => {
- const countShelves = 5;
- const availableSpace = countShelves * 8;
- let countShelves1 = 5.5
- let availableSpace1 = countShelves1 * 8;
- let countShelves2 = 0
- let availableSpace2 = countShelves2 * 8;
- let countShelves4 = 1
- let availableSpace4 = countShelves4 * 8;
- assert.equal(library.arrangeTheBooks(availableSpace, countShelves), "Great job, the books are arranged.");
- assert.equal(library.arrangeTheBooks(availableSpace1, countShelves1), "Insufficient space, more shelves need to be purchased.");
- assert.equal(library.arrangeTheBooks(availableSpace2, countShelves2), "Great job, the books are arranged.");
- assert.equal(library.arrangeTheBooks(availableSpace4, countShelves4), "Great job, the books are arranged.");
- })
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement