Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

Axiomatik avatar Axiomatik 2422 Точки

frown, check zero test #2.

searchCar :

    • There is a need for validation of the input, a shop and a model mаy not always be valid. In case of submitted invalid parameters, throw an error "Invalid input!";

    • If there are no matching elements, the function throw an error: 'There are no such models in the catalog!'

calculatePriceOfCar :

    • There is a need for validation of the input, a model, and days mаy not always be valid. In case of submitted invalid parameters, throw an error "Invalid input!";

    • Otherwise, if there is no such model, the function throw an error: 'No such model in the catalog!'.

checkBudget :

    • If the budget is less than cost, the function returns the message: 'You need a bigger budget!'.  // You need a bigger budged!

 

 

1
17/02/2023 20:08:33
Marin171 avatar Marin171 2 Точки

describe("rentCar test suit", function () {

    describe("searchCar", function () {

        it("When there are matching elements return count", function () {

            assert(rentCar.searchCar(["Volkswagen", "BMW", "Audi", "BMW"], 'BMW'),

                'There is 2 car of model BMW in the catalog!');

 

            assert(rentCar.searchCar(["Volkswagen", "BMW", "Audi", "BMW"], 'Audi'),

                'There is 1 car of model Audi in the catalog!')

        });

 

        it('In case of submitted invalid parameters, throw an error "Invalid input!"', () => {

            assert.throws(() => rentCar.searchCar(), Error, 'Invalid input!');

            assert.throws(() => rentCar.searchCar(1, 2), Error, 'Invalid input!');

            assert.throws(() => rentCar.searchCar('["A","B"]', null), Error, 'Invalid input!');

        })

 

        it('If there are no matching elements, the function throw an error', () => {

            assert.throws(() => rentCar.searchCar(["Volkswagen", "BMW", "Audi", "BMW"], 'Moskvich'),

                Error, 'There are no such models in the catalog!');

 

            assert.throws(() => rentCar.searchCar(["Volkswagen", "BMW", "Audi", "BMW"], 'Ford'),

                Error, 'There are no such models in the catalog!');

        })

    });

 

    describe('calculatePriceOfCar', () => {

        it('In case of submitted invalid parameters, throw an error "Invalid input!"', () => {

            assert.throws(() => rentCar.calculatePriceOfCar(), Error, 'Invalid input!');

            assert.throws(() => rentCar.calculatePriceOfCar('Ford', 2.2), Error, 'Invalid input!');

            assert.throws(() => rentCar.calculatePriceOfCar(null, 2), Error, 'Invalid input!');

        });

 

        it('returns the model and the price it will cost ', () => {

            assert.equal(rentCar.calculatePriceOfCar('BMW', 2),

                'You choose BMW and it will cost $90!');

            assert.equal(rentCar.calculatePriceOfCar('Mercedes', 3),

                'You choose Mercedes and it will cost $150!');

        });

 

        it('if there is no such model, the function throw an error: No such model in the catalog!',()=>{

            assert.throws(()=>rentCar.calculatePriceOfCar('Lada', 10), Error, 'No such model in the catalog!');

        });

    });

 

    describe('checkBudget', ()=>{

        it('Validates input', ()=>{

            assert.throws(()=>rentCar.checkBudget(), Error, 'Invalid input!')

            assert.throws(()=>rentCar.checkBudget('1', 2, 3), Error, 'Invalid input!')

            assert.throws(()=>rentCar.checkBudget(1,'2',3), Error, 'Invalid input!')

            assert.throws(()=>rentCar.checkBudget(1,2,'3'), Error, 'Invalid input!')

        });

 

        it('If the budget is bigger or equal to cost, function return: You rent a car!',()=>{

            assert.equal(rentCar.checkBudget(10,10,150), 'You rent a car!');

            assert.equal(rentCar.checkBudget(10,10,100), 'You rent a car!');

        });

 

        it('If the budget is less than cost, the function returns the message: You need a bigger budget!',()=>{

            assert.equal(rentCar.checkBudget(10,10,95), 'You need a bigger budget!');

        });

    })

});

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.