/* global expect test */
const { Lyric } = require('./musixmatch');
const BlockedError = require('../include/blocked_error');

async function testLyric(obj) {
  const { url } = obj;
  const inst = new Lyric(url);
  try {
    await inst.get();
  } catch (e) {
    if (e instanceof BlockedError) {
      console.warn('Blocked by vendor');
      return;
    }
  }

  expect(inst.title).toBe(obj.title);
  expect(inst.artist).toBe(obj.artist);
  if (obj.lyricist) expect(inst.lyricist).toBe(obj.lyricist);
  if (obj.composer) expect(inst.composer).toBe(obj.composer);
  if (obj.length) expect(inst.lyric.length).toBe(obj.length);
}

test('', async () => {
  await testLyric({
    url:
      'https://www.musixmatch.com/lyrics/SawanoHiroyuki-nZk-Tielle-Gemie/sh0ut',
    title: 'sh0ut',
    artist: 'SawanoHiroyuki[nZk]:Tielle&Gemie',
    length: 1719,
  });
});

test('', async () => {
  await testLyric({
    url:
      'https://www.musixmatch.com/lyrics/Mariah-Carey-feat-Ne%E2%80%90Yo/Angels-Cry',
    title: 'Angels Cry',
    artist: 'Mariah Carey feat. Ne-Yo',
    length: 1808,
  });
});

@@ -895,38 +895,32 @@
 Lyric(%7B%0A    url:
-%0A     
  'https://www.mu
@@ -943,49 +943,26 @@
 ics/
-Mariah-Carey-feat-Ne%25E2%2580%2590Yo/Angels-Cr
+L-Arc-en-Ciel/Hone
 y',%0A
@@ -976,20 +976,15 @@
 le: 
-'Angels Cry'
+%22Honey%22
 ,%0A  
@@ -997,34 +997,23 @@
 st: 
-'Mariah Carey feat. Ne-Yo'
+%22L'Arc-en-Ciel%22
 ,%0A  
@@ -1026,12 +1026,11 @@
 th: 
-1808
+433
 ,%0A  

change musixmatch test url