Guest User

Untitled

a guest
Nov 25th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. //Zero Test - Move
  2. document.body.innerHTML = `
  3. <h1>Ski Inventory</h1>
  4. <section id="products">
  5. <h2>Available Products</h2>
  6. <ul>
  7. </ul>
  8. <div class="filter">
  9. <label>Filter</label>
  10. <input id="filter" type="text" placeholder="Search by name..." />
  11. <button>Filter</button>
  12. </div>
  13. </section>
  14. <form id="add-new">
  15. <h2>Add Product</h2>
  16. <input type="text" placeholder="Name" />
  17. <input type="text" placeholder="Quantity" />
  18. <input type="text" placeholder="Price" />
  19. <button>Add</button>
  20. </form>
  21. <h1>Total Price: 00.00</h1>
  22. <section id="myProducts">
  23. <h2>My Products</h2>
  24. <ul>
  25. </ul>
  26. <button>Buy</button>
  27. </section>
  28. `;
  29.  
  30.  
  31. result();
  32.  
  33. let inputFields = document.querySelectorAll('form input');
  34. let formButton = document.querySelector('form button');
  35. let sections = document.querySelector('section');
  36.  
  37.  
  38.  
  39. inputFields[0].value = 'Dynamic Slalom Carver';
  40. inputFields[1].value = "3";
  41. inputFields[2].value = '55.50';
  42.  
  43. formButton.click();
  44. //Add to new Books
  45. let avProducts = document.querySelectorAll("#products ul li");
  46. let available = avProducts[0].children[1];
  47. let addBtn = avProducts[0].children[2].children[1];
  48.  
  49. //Move
  50. addBtn.click();
  51. assert.equal(available.textContent,"Available: 2","Quantity is incorrect");
  52.  
  53. let totalPrice = document.querySelectorAll('h1')[1];
  54. assert.equal(totalPrice.textContent, "Total Price: 55.50", "Total price is incorrect");
  55.  
  56. //MyProducts Structure
  57. let myProducts = document.querySelectorAll('#myProducts ul li');
  58. assert.equal(myProducts[0].children.length,1,"my products structure is incorrect");
  59. assert.equal(myProducts[0].children[0].tagName,"STRONG","strong in my products is incorrect");
  60. assert.equal(myProducts[0].textContent,"Dynamic Slalom Carver55.50","My products text is incorrect");
Advertisement
Add Comment
Please, Sign In to add comment