<commit_before>import { module } from 'substance-test'
import { Document, EditingInterface } from 'substance'
import fixture from './fixture/createTestArticle'
import simple from './fixture/simple'

const test = module('paste')

test("Pasting plain text", function(t) {
  let { tx } = _fixture(simple)
  tx.setSelection({
    type: 'property',
    path: ['p1', 'content'],
    startOffset: 3
  })
  tx.paste('XXX')
  let p1 = tx.get('p1')
  t.equal(p1.content, '012XXX3456789')
  t.end()
})

test("Pasting a single paragraph", function(t) {
  let { tx } = _fixture(simple)
  let snippet = tx.createSnippet()
  let container = snippet.getContainer()
  let p = snippet.create({
    type: 'paragraph',
    id: Document.TEXT_SNIPPET_ID,
    content: 'AABBCC'
  })
  container.show(p.id)
  tx.setSelection({
    type: 'property',
    path: ['p1', 'content'],
    startOffset: 3,
    containerId: 'body'
  })
  tx.paste(snippet)
  let p1 = tx.get('p1')
  t.equal(p1.content, '012AABBCC3456789', 'Plain text should be inserted.')
  t.end()
})

test("Pasting annotated text", function(t) {
  let { tx } = _fixture(simple)
  tx.setSelection({
    type: 'property',
    path: ['p1', 'content'],
    startOffset: 3,
    containerId: 'body'
  })
  let snippet = tx.createSnippet()
  let container = snippet.getContainer()
  let p = snippet.create({
    type: 'paragraph',
    id: Document.TEXT_SNIPPET_ID,
    content: 'AABBCC'
  })
  container.show(p.id)
  snippet.create({
    type: 'strong',
    id: 's1',
    start: {
      path: [p.id, 'content'],
      offset: 2,
    },
    end: {
      offset: 4
    }
  })
  tx.paste(snippet)
  let p1 = tx.get('p1')
  t.equal(p1.content, '012AABBCC3456789', 'Plain text should be inserted.')
  let s1 = tx.get('s1')
  t.deepEqual(s1.path, [p1.id, 'content'], 'Annotation is bound to the correct path.')
  t.deepEqual([s1.start.offset, s1.end.offset], [5, 7], 'Annotation has correct range.')
  t.end()
})

test("Pasting two paragraphs", function(t) {<commit_msg>Eliminate deprecation warning.<commit_after>import { module } from 'substance-test'
import { Document, EditingInterface } from 'substance'
import fixture from './fixture/createTestArticle'
import simple from './fixture/simple'

const test = module('paste')

test("Pasting plain text", function(t) {
  let { tx } = _fixture(simple)
  tx.setSelection({
    type: 'property',
    path: ['p1', 'content'],
    startOffset: 3
  })
  tx.paste('XXX')
  let p1 = tx.get('p1')
  t.equal(p1.content, '012XXX3456789')
  t.end()
})

test("Pasting a single paragraph", function(t) {
  let { tx } = _fixture(simple)
  let snippet = tx.createSnippet()
  let container = snippet.getContainer()
  let p = snippet.create({
    type: 'paragraph',
    id: Document.TEXT_SNIPPET_ID,
    content: 'AABBCC'
  })
  container.show(p.id)
  tx.setSelection({
    type: 'property',
    path: ['p1', 'content'],
    startOffset: 3,
    containerId: 'body'
  })
  tx.paste(snippet)
  let p1 = tx.get('p1')
  t.equal(p1.content, '012AABBCC3456789', 'Plain text should be inserted.')
  t.end()
})

test("Pasting annotated text", function(t) {
  let { tx } = _fixture(simple)
  tx.setSelection({
    type: 'property',
    path: ['p1', 'content'],
    startOffset: 3,
    containerId: 'body'
  })
  let snippet = tx.createSnippet()
  let container = snippet.getContainer()
  let p = snippet.create({
    type: 'paragraph',
    id: Document.TEXT_SNIPPET_ID,
    content: 'AABBCC'
  })
  container.show(p.id)
  snippet.create({
    type: 'strong',
    id: 's1',
    start: {
      path: [p.id, 'content'],
      offset: 2,
    },
    end: {
      offset: 4
    }
  })
  tx.paste(snippet)
  let p1 = tx.get('p1')
  t.equal(p1.content, '012AABBCC3456789', 'Plain text should be inserted.')
  let s1 = tx.get('s1')
  t.deepEqual(s1.start.path, [p1.id, 'content'], 'Annotation is bound to the correct path.')
  t.deepEqual([s1.start.offset, s1.end.offset], [5, 7], 'Annotation has correct range.')
  t.end()
})

test("Pasting two paragraphs", function(t) {
{'fraction_non_alphanumeric': 0.167622848590671, 'fraction_numerical': 0.027937141431778497, 'mean_word_length': 3.4211686879823593, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '2313238', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1465, 'n_words': 346}