Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('Tests library', function () {
- describe('calcPriceOfBook ', function () {
- it('assert with valid params', function () {
- assert.equal(
- library.calcPriceOfBook('Some book', 1980),
- 'Price of Some book is 10.00'
- );
- assert.equal(
- library.calcPriceOfBook('Some book', 1979),
- 'Price of Some book is 10.00'
- );
- assert.equal(
- library.calcPriceOfBook('Some book', 1981),
- 'Price of Some book is 20.00'
- );
- assert.equal(
- library.calcPriceOfBook('Some book', 0),
- 'Price of Some book is 10.00'
- );
- });
- it('assert with invalid params, expect to throw', function () {
- assert.Throw(
- () => library.calcPriceOfBook('Some book'),
- 'Invalid input'
- );
- assert.Throw(
- () => library.calcPriceOfBook('Some book', '1987'),
- 'Invalid input'
- );
- assert.Throw(
- () => library.calcPriceOfBook('Some book', [1987]),
- 'Invalid input'
- );
- assert.Throw(
- () => library.calcPriceOfBook('Some book', 1987.6),
- 'Invalid input'
- );
- assert.Throw(
- () => library.calcPriceOfBook(['Some book'], 0),
- 'Invalid input'
- );
- assert.Throw(() => library.calcPriceOfBook(0, 0), 'Invalid input');
- assert.Throw(() => library.calcPriceOfBook(1876), 'Invalid input');
- });
- });
- describe('findBook', function () {
- it('assert with valid param', function () {
- assert.equal(
- library.findBook(
- ['Troy', 'Life Style', 'Torronto'],
- 'Some book'
- ),
- 'The book you are looking for is not here!'
- );
- assert.equal(
- library.findBook(['Troy', 'Life Style', 'Torronto'], 'Troy'),
- 'We found the book you want.'
- );
- });
- it('assert with valid param, [] - throw', function () {
- assert.Throw(
- () => library.findBook([], 'Some book'),
- 'No books currently available'
- );
- });
- });
- describe('arrangeTheBooks', function () {
- it('assert with valid params', function () {
- assert.equal(
- library.arrangeTheBooks(6),
- 'Great job, the books are arranged.'
- );
- assert.equal(
- library.arrangeTheBooks(40),
- 'Great job, the books are arranged.'
- );
- assert.equal(
- library.arrangeTheBooks(41),
- 'Insufficient space, more shelves need to be purchased.'
- );
- assert.equal(
- library.arrangeTheBooks(0),
- 'Great job, the books are arranged.'
- );
- });
- it('assert with invalid params', function () {
- assert.throw(() => library.arrangeTheBooks(-1), 'Invalid input');
- assert.throw(() => library.arrangeTheBooks(), 'Invalid input');
- assert.throw(() => library.arrangeTheBooks(8.7), 'Invalid input');
- assert.throw(() => library.arrangeTheBooks('8'), 'Invalid input');
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement