Guest User

Untitled

a guest
Nov 21st, 2019
108
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe("SoftUnify Test Suite", function() {
  2. let testInstance;
  3. this.beforeEach(() => {
  4. testInstance = new SoftUnify();
  5. });
  6.  
  7. const [testArtist, testSong, testLyrics, invalidData] = [
  8. "theKing",
  9. "smallSong",
  10. "shortLyrics",
  11. "invalid"
  12. ];
  13.  
  14. describe("Initialization tests", function() {
  15. it("can be instantiated with string no parameters", function() {
  16. assert.exists(testInstance);
  17. assert.exists(testInstance.allSongs);
  18. assert.deepEqual(testInstance.allSongs, {});
  19. });
  20.  
  21. describe("downloadSong(artist, song, lyrics) tests", function() {
  22. it("adds the given information to the allSongs", function() {
  23. assert.isFalse(testInstance.allSongs.hasOwnProperty(testArtist));
  24. let result = testInstance.downloadSong(
  25. testArtist,
  26. testSong,
  27. testLyrics
  28. );
  29. assert.equal(testInstance, result);
  30. assert.isTrue(testInstance.allSongs.hasOwnProperty(testArtist));
  31. const expectedRecord = {
  32. rate: 0,
  33. votes: 0,
  34. songs: [`${testSong} - ${testLyrics}`]
  35. };
  36.  
  37. assert.deepEqual(expectedRecord, testInstance.allSongs[testArtist]);
  38. });
  39. });
  40.  
  41. // describe("playSong(song) tests", function() {
  42. // it("returns fail message if no songs at all", function() {
  43. // const expectedMessage = `You have not downloaded a ${testSong} song yet. Use SoftUniFy's function downloadSong() to change that!`;
  44. // const actualMessage = testInstance.playSong(testSong);
  45. // assert.equal(expectedMessage, actualMessage);
  46. // });
  47.  
  48. // it("returns fail message if no such song exist", function() {
  49. // testInstance.downloadSong(testArtist, testSong, testLyrics);
  50.  
  51. // const expectedMessage = `You have not downloaded a ${invalidData} song yet. Use SoftUniFy's function downloadSong() to change that!`;
  52. // const actualMessage = testInstance.playSong(invalidData);
  53. // assert.equal(expectedMessage, actualMessage);
  54. // });
  55.  
  56. // it("returns correctData if Song is found", function() {
  57. // testInstance.downloadSong(testArtist, testSong, testLyrics);
  58.  
  59. // const expectedMessage = `${testArtist}:\n${testSong} - ${testLyrics}\n`;
  60. // const actualMessage = testInstance.playSong(testSong);
  61. // assert.equal(expectedMessage, actualMessage);
  62. // });
  63.  
  64. // it("returns correctData if MoreThanOneSIngerSings same Song", function() {
  65. // const secondArtist = "testArtist2";
  66.  
  67. // testInstance.downloadSong(testArtist, testSong, testLyrics);
  68. // testInstance.downloadSong(invalidData, invalidData, invalidData);
  69. // testInstance.downloadSong(secondArtist, testSong, testLyrics);
  70.  
  71. // const expectedMessage =
  72. // `${testArtist}:\n${testSong} - ${testLyrics}\n` +
  73. // `${secondArtist}:\n${testSong} - ${testLyrics}\n`;
  74. // const actualMessage = testInstance.playSong(testSong);
  75. // assert.equal(expectedMessage, actualMessage);
  76. // });
  77. // });
  78.  
  79. // describe("songsList() tests", function() {
  80. // it("returns proper message if no songs at all", function() {
  81. // const expectedMessage = "Your song list is empty";
  82. // const actualMessage = testInstance.songsList;
  83. // assert.equal(expectedMessage, actualMessage);
  84. // });
  85.  
  86. // it("returns all Songs Properly", function() {
  87. // testInstance.downloadSong(testArtist, testSong, testLyrics);
  88. // let expectedMessage = `${testSong} - ${testLyrics}`;
  89. // let actualMessage = testInstance.songsList;
  90. // assert.equal(expectedMessage, actualMessage);
  91. // const secondSong = "secondSong";
  92. // testInstance.downloadSong(testArtist, secondSong, testLyrics);
  93. // expectedMessage = `${testSong} - ${testLyrics}\n${secondSong} - ${testLyrics}`;
  94. // actualMessage = testInstance.songsList;
  95. // assert.equal(expectedMessage, actualMessage);
  96. // });
  97. // });
  98.  
  99. // describe("songsList() tests", function() {
  100. // it("returns proper message if no songs at all", function() {
  101. // const expectedMessage = "Your song list is empty";
  102. // const actualMessage = testInstance.songsList;
  103. // assert.equal(expectedMessage, actualMessage);
  104. // });
  105.  
  106. // it("returns all Songs Properly", function() {
  107. // testInstance.downloadSong(testArtist, testSong, testLyrics);
  108. // let expectedMessage = `${testSong} - ${testLyrics}`;
  109. // let actualMessage = testInstance.songsList;
  110. // assert.equal(expectedMessage, actualMessage);
  111. // const secondSong = "secondSong";
  112. // testInstance.downloadSong(testArtist, secondSong, testLyrics);
  113. // expectedMessage = `${testSong} - ${testLyrics}\n${secondSong} - ${testLyrics}`;
  114. // actualMessage = testInstance.songsList;
  115. // assert.equal(expectedMessage, actualMessage);
  116. // });
  117. // });
  118.  
  119. // describe("rateArtist() tests", function() {
  120. // it("returns Singer Not Found message", function() {
  121. // const expectedMessage = `The ${invalidData} is not on your artist list.`;
  122. // let actualMessage = testInstance.rateArtist(invalidData);
  123. // assert.equal(expectedMessage, actualMessage);
  124. // actualMessage = testInstance.rateArtist(invalidData, 1);
  125. // assert.equal(expectedMessage, actualMessage);
  126. // });
  127. // this.beforeEach(() => {
  128. // testInstance.downloadSong(testArtist, testSong, testLyrics);
  129. // });
  130.  
  131. // it("Modifies Singer Rate", function() {
  132. // assert.equal(0, testInstance.allSongs[testArtist].rate);
  133. // assert.equal(0, testInstance.allSongs[testArtist].votes);
  134. // testInstance.rateArtist(testArtist, 1);
  135. // assert.equal(1, testInstance.allSongs[testArtist].rate);
  136. // assert.equal(1, testInstance.allSongs[testArtist].votes);
  137. // });
  138.  
  139. // it("Returns Average Vote Singer Rate", function() {
  140. // testInstance.rateArtist(testArtist, 1);
  141. // testInstance.rateArtist(testArtist, 0);
  142. // let actualMessage = testInstance.rateArtist(testArtist, 1);
  143. // const expectedMessage = "0.67";
  144. // assert.equal(expectedMessage, actualMessage);
  145. // assert.equal(2, testInstance.allSongs[testArtist].rate);
  146. // assert.equal(3, testInstance.allSongs[testArtist].votes);
  147. // });
  148. // });
  149. });
  150. });
RAW Paste Data