$ = jQuery = require('jquery');
require('jquery-ui-1-11-4');

// Mock for qvitter.js
global.checkLocalStorage = () => {};
global.iterateRecursiveReplaceHtmlSpecialChars = () => {};
global.document.execCommand = function execCommandMock(text1, bool, text2) {
  document.body.innerText = text2;
};

const qvitter = require('./qvitter');
const miscFunctions = require('./misc-functions');
const stripHtmlFromPaste = qvitter.__get__('stripHtmlFromPaste');

// Mock for stripHtmlFromPaste
global.replaceHtmlSpecialChars = miscFunctions.__get__('replaceHtmlSpecialChars');

describe('stripHtmlFromPaste', () => {
  // Mock for clipboard API
  class ClipboardEventMock {
    constructor(data) {
      class DataTransfer {
        constructor(data) {          
        }
        getData(mimeType) {
          return data;
        }
      }
      this.clipboardData = new DataTransfer(data);
    }
    preventDefault() {}
  }
  it('has empty background-image URL.', () => {    
    const e = new ClipboardEventMock(' hello ');
    stripHtmlFromPaste(e);
    expect(document.body.innerText).toBe('&nbsp;hello&nbsp;');
  });
});
