Advertisement
zornitsa_zlateva

Judge test_Task Manager

Mar 12th, 2022
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.body.innerHTML = `
  2. <main>
  3.     <div class="wrapper">
  4.         <section>
  5.             <div>
  6.                 <h1 class="gray">Add Task</h1>
  7.             </div>
  8.             <div>
  9.                 <form action="">
  10.                     <label for="task">Task</label><br>
  11.                     <input type="text" id="task" name="task" placeholder="JS Advanced Exam"><br>
  12.                     <label for="description">Description</label><br>
  13.                     <textarea id="description" placeholder="Lern DOM, Unit Testing and Classes"></textarea>
  14.                     <label for="date">Due Date</label><br>
  15.                     <input type="text" id="date" name="date" placeholder="2020.04.08"><br>
  16.                     <button id="add">Add</button>
  17.                 </form>
  18.             </div>
  19.         </section>
  20.  
  21.         <section>
  22.             <div>
  23.                 <h1 class="orange">Open</h1>
  24.             </div>
  25.             <div>
  26.                
  27.             </div>
  28.         </section>
  29.         <section>
  30.             <div>
  31.                 <h1 class="yellow">In Progress</h1>
  32.             </div>
  33.             <div id="in-progress">
  34.                
  35.             </div>
  36.         </section>
  37.         <section>
  38.             <div>
  39.                 <h1 class="green">Complete</h1>
  40.             </div>
  41.             <div>
  42.                
  43.             </div>
  44.         </section>
  45.     </div>
  46. </main>
  47. `;
  48.  
  49. result();
  50.  
  51. let elements = {
  52.     task: document.getElementById("task"),
  53.     description: document.getElementById("description"),
  54.     date: document.getElementById("date"),
  55. }
  56. elements["addButton"] = document.getElementById("add");
  57.  
  58. elements.task.value = "JS Advanced Exam";
  59. elements.description.value = "Lern DOM, Unit Testing and Classes";
  60. elements.date.value = "2020.04.08";
  61.  
  62. let sections = document.getElementsByTagName("section");
  63. let open = sections[1];
  64. let inProgress = sections[2];
  65. let complete = sections[3];
  66.  
  67. elements.addButton.click();
  68.  
  69. assert.equal(open.children.length, 2, "Incorrect count of added tasks in 'Open' section");
  70. assert.equal(open.children[1].children[0].tagName, "ARTICLE", "Incorrect tagname");
  71. assert.equal(open.children[1].children[0].children.length, 4, "Incorrect count of added HTML Elements in the article tag");
  72. assert.equal(open.children[1].children[0].children[0].textContent, "JS Advanced Exam", "Incorrect Task name");
  73. assert.equal(open.children[1].children[0].children[1].textContent, "Description: Lern DOM, Unit Testing and Classes", "Incorrect description");
  74. assert.equal(open.children[1].children[0].children[2].textContent, "Due Date: 2020.04.08", "Incorrect date");
  75. assert.equal(open.children[1].children[0].children[3].children.length, 2, "Incorrect count of buttons");
  76.  
  77. let delBtn = open.children[1].children[0].children[3].children[1];
  78. delBtn.click();
  79.  
  80. //testing if task is deleted
  81. assert.equal(open.children[1].children.length, 0, "Incorrect count of children elements in 'Open' section");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement