Home > front end >  Js on mocha test will use three methods
Js on mocha test will use three methods

Time:10-11

Search (criteria) - returns an array containing the product objects that match the criteria argument. The criteria is a single - property object where the key is either 'price' or 'keyword'. When the key is' price, it returns the products whose price is less than (or equal to) the specified value, e.g.
Search () {price: 25.00}
Should return products cheaper than euro 25.01.

When the key is' keyword 'it returns the products have the keyword in their name, e.g.
Search ({keyword: "sho"})
Should return products with 'sho' in the name (e.g., shoes, shoulder bag).

If the criteria object has neither the key then an exception should be thrown with the message 'Bad search'. A simple example of the method invocation took be:
Const result=catalogue. The search ({keyword: "Widget"})
The console. The log (result [0]. Name)//Display the name of the first product object
  • Related