<commit_before>const assert = require('assert')
const path = require('path')

const clipboard = require('electron').clipboard
const nativeImage = require('electron').nativeImage

describe('clipboard module', function () {
  var fixtures = path.resolve(__dirname, 'fixtures')

  describe('clipboard.readImage()', function () {
    it('returns NativeImage intance', function () {
      var p = path.join(fixtures, 'assets', 'logo.png')
      var i = nativeImage.createFromPath(p)
      clipboard.writeImage(p)
      assert.equal(clipboard.readImage().toDataURL(), i.toDataURL())
    })
  })

  describe('clipboard.readText()', function () {
    it('returns unicode string correctly', function () {
      var text = '千江有水千江月，万里无云万里天'
      clipboard.writeText(text)
      assert.equal(clipboard.readText(), text)
    })
  })

  describe('clipboard.readHTML()', function () {
    it('returns markup correctly', function () {
      var text = '<string>Hi</string>'
      var markup = process.platform === 'darwin' ? "<meta charset='utf-8'><string>Hi</string>" : process.platform === 'linux' ? '<meta http-equiv="content-type" ' + 'content="text/html; charset=utf-8"><string>Hi</string>' : '<string>Hi</string>'
      clipboard.writeHTML(text)
      assert.equal(clipboard.readHTML(), markup)
    })
  })

  describe('clipboard.readRTF', function () {
    it('returns rtf text correctly', function () {
      var rtf = '{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}'
      clipboard.writeRTF(rtf)
      assert.equal(clipboard.readRTF(), rtf)
    })
  })

  describe('clipboard.readBookmark', function () {
    it('returns title and url', function () {
      clipboard.writeBookmark('a title', 'http://electron.atom.io')
      assert.deepEqual(clipboard.readBookmark(), {
        title: 'a title',
        url: 'https://electron.atom.io'
      })
    })
  })

  describe('clipboard.write()', function () {
    it('returns data correctly', function () {
      var text = 'test'
      var rtf = '{\\rtf1\\utf8 text}'
      var p = path.join(fixtures, 'assets', 'logo.png')
      var i = nativeImage.createFromPath(p)
      var markup = process.platform === 'darwin' ? "<meta charset='utf-8'><b>Hi</b>" : process.platform === 'linux' ? '<meta http-equiv="content-type" ' + 'content="text/html; charset=utf-8"><b>Hi</b>' : '<b>Hi</b>'
      var bookmark = {title: 'a title', url: 'test'}
      clipboard.write({
        text: 'test',
        html: '<b>Hi</b>',
        rtf: '{\\rtf1\\utf8 text}',<commit_msg>Add assertions for no available bookmark<commit_after>const assert = require('assert')
const path = require('path')

const clipboard = require('electron').clipboard
const nativeImage = require('electron').nativeImage

describe('clipboard module', function () {
  var fixtures = path.resolve(__dirname, 'fixtures')

  describe('clipboard.readImage()', function () {
    it('returns NativeImage intance', function () {
      var p = path.join(fixtures, 'assets', 'logo.png')
      var i = nativeImage.createFromPath(p)
      clipboard.writeImage(p)
      assert.equal(clipboard.readImage().toDataURL(), i.toDataURL())
    })
  })

  describe('clipboard.readText()', function () {
    it('returns unicode string correctly', function () {
      var text = '千江有水千江月，万里无云万里天'
      clipboard.writeText(text)
      assert.equal(clipboard.readText(), text)
    })
  })

  describe('clipboard.readHTML()', function () {
    it('returns markup correctly', function () {
      var text = '<string>Hi</string>'
      var markup = process.platform === 'darwin' ? "<meta charset='utf-8'><string>Hi</string>" : process.platform === 'linux' ? '<meta http-equiv="content-type" ' + 'content="text/html; charset=utf-8"><string>Hi</string>' : '<string>Hi</string>'
      clipboard.writeHTML(text)
      assert.equal(clipboard.readHTML(), markup)
    })
  })

  describe('clipboard.readRTF', function () {
    it('returns rtf text correctly', function () {
      var rtf = '{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}'
      clipboard.writeRTF(rtf)
      assert.equal(clipboard.readRTF(), rtf)
    })
  })

  describe('clipboard.readBookmark', function () {
    it('returns title and url', function () {
      clipboard.writeBookmark('a title', 'http://electron.atom.io')
      assert.deepEqual(clipboard.readBookmark(), {
        title: 'a title',
        url: 'http://electron.atom.io'
      })

      clipboard.writeText('no bookmark')
      assert.deepEqual(clipboard.readBookmark(), {
        title: '',
        url: ''
      })
    })
  })

  describe('clipboard.write()', function () {
    it('returns data correctly', function () {
      var text = 'test'
      var rtf = '{\\rtf1\\utf8 text}'
      var p = path.join(fixtures, 'assets', 'logo.png')
      var i = nativeImage.createFromPath(p)
      var markup = process.platform === 'darwin' ? "<meta charset='utf-8'><b>Hi</b>" : process.platform === 'linux' ? '<meta http-equiv="content-type" ' + 'content="text/html; charset=utf-8"><b>Hi</b>' : '<b>Hi</b>'
      var bookmark = {title: 'a title', url: 'test'}
      clipboard.write({
        text: 'test',
        html: '<b>Hi</b>',
        rtf: '{\\rtf1\\utf8 text}',
{'fraction_non_alphanumeric': 0.1865373645179692, 'fraction_numerical': 0.004183304810800532, 'mean_word_length': 3.336356141797197, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1432017', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1698, 'n_words': 325}