Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe("Testing the object library", function () {
- describe("First method tests", function () {
- it("Should have an input like this: (string, number)", function () {
- expect(() => library.calcPriceOfBook(123, 1978)).to.throw("Invalid input");
- expect(() => library.calcPriceOfBook('dass', 'das')).to.throw("Invalid input");
- expect(() => library.calcPriceOfBook(123, 'das')).to.throw("Invalid input");
- expect(() => library.calcPriceOfBook('asda', 1988.12)).to.throw("Invalid input");
- });
- it('Should calculate the price depending on the year', () => {
- let returnValue = library.calcPriceOfBook('War and Peace', 1990);
- let returnValue2 = library.calcPriceOfBook('War and Peace', 1970);
- expect(returnValue).to.equal('Price of War and Peace is 20.00');
- expect(returnValue2).to.equal('Price of War and Peace is 10.00');
- });
- });
- describe('Second method', () => {
- it('Should include all books in library', () => {
- });
- it('Should return proper strings', () => {
- let returnValue = library.findBook(['some', 'troy'], 'some');
- let returnValue2 = library.findBook(['some', 'troy'], 'dasda');
- expect(returnValue).to.equal('We found the book you want.');
- expect(returnValue2).to.equal('The book you are looking for is not here!');
- });
- it('Should check the length of the array', () => {
- expect(() => library.findBook([], 'some')).to.throw("No books currently available");
- });
- });
- describe('Third method', () => {
- it('Should have a positive integer as a parameter', () => {
- expect(() => library.arrangeTheBooks(-12)).to.throw("Invalid input");
- expect(() => library.arrangeTheBooks(1.54)).to.throw("Invalid input");
- });
- it('Should check the space for the books', () => {
- expect(library.arrangeTheBooks(40)).to.equal('Great job, the books are arranged.');
- expect(library.arrangeTheBooks(41)).to.equal('Insufficient space, more shelves need to be purchased.');
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement