Advertisement
Todorov_Stanimir

03. Softunify JS Advanced Exam Preparation - July 2019

Oct 20th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe("class SoftUniFy", () => {
  2.     //test 1
  3.     it("checking property of instance", () => {
  4.         let softunify = new SoftUniFy();
  5.         expect(softunify.allSongs).to.be.a('object');
  6.         expect(softunify).to.have.property('allSongs');
  7.     });
  8.     //test 1 and 2
  9.     it("checking method downloadSong(artist, song, lyrics)", () => {
  10.         let softunify = new SoftUniFy();
  11.         softunify.downloadSong('Eminem', 'Venom', 'Knock, Knock let the devil in...');
  12.         let result = softunify.downloadSong('Eminem', 'Phenomenal', 'IM PHENOMENAL...');
  13.         expect(result).deep.equal({ "allSongs": { "Eminem": { "rate": 0, "songs": ['Venom - Knock, Knock let the devil in...', 'Phenomenal - IM PHENOMENAL...'], "votes": 0, } } });
  14.         expect(result.allSongs['Eminem']["rate"]).equal(0);
  15.     });
  16.     // test 1, 2, 3, 4, 5, 6, 7, 8 and 9
  17.     it("checking method playSong(song)", () => {
  18.         let softunify = new SoftUniFy();
  19.         softunify.downloadSong('Eminem', 'Venom', 'Knock, Knock let the devil in...');
  20.         let result = softunify.playSong('Phenomenal')
  21.         expect(result).equal(`You have not downloaded a Phenomenal song yet. Use SoftUniFy's function downloadSong() to change that!`);
  22.    });
  23.    //test 1, 2, 4, 5, 8 and 9
  24.    it("checking getter songsList", () => {
  25.        let softunify = new SoftUniFy(1);
  26.        let result = softunify.songsList;
  27.        expect(result).equal('Your song list is empty');
  28.        softunify.downloadSong('Eminem', 'Venom', 'Knock, Knock let the devil in...');
  29.        softunify.downloadSong('Eminem', 'Phenomenal', 'IM PHENOMENAL...')
  30.        result = softunify.songsList;
  31.        expect(result).equal('Venom - Knock, Knock let the devil in...\nPhenomenal - IM PHENOMENAL...');
  32.    });
  33.    // test 1, 2, 6, 7 and 10
  34.    it("checking method rateArtist('artist)", () => {
  35.        let softunify = new SoftUniFy();
  36.        softunify.downloadSong('Eminem', 'Venom', 'Knock, Knock let the devil in...');
  37.        softunify.downloadSong('Eminem', 'Phenomenal', 'IM PHENOMENAL...');
  38.        let result = softunify.rateArtist('artist')
  39.        expect(result).equal(`The artist is not on your artist list.`);
  40.    });
  41.    // test 1, 2, 6, 7 and 10
  42.    it("checking method rateArtist('Eminem', 10)", () => {
  43.        let softunify = new SoftUniFy();
  44.        softunify.downloadSong('Eminem', 'Venom', 'Knock, Knock let the devil in...');
  45.        softunify.downloadSong('Eminem', 'Phenomenal', 'IM PHENOMENAL...');
  46.        softunify.rateArtist('Eminem', 10);
  47.        let result = softunify.rateArtist('Eminem', 5);
  48.        expect(result).equal(7.50);
  49.    });
  50. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement