G2A Many GEOs
SHARE
TWEET

Untitled

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