<commit_before>/* @flow */
import test from 'tape'
import {assign} from 'lodash/object'
import {cloneDeep} from 'lodash/lang'
import {sysMock, linkMock} from '../mocks'

import {wrapEntry, wrapEntryCollection} from '../../../lib/entities/entry'

const entry = {
  sys: assign(cloneDeep(sysMock), {
    type: 'Entry',
    contentType: assign(cloneDeep(linkMock), {linkType: 'ContentType'}),
    locale: 'locale'
  }),
  fields: {
    field1: 'str'
  }
}

test.only('Entry is wrapped', t => {
  const wrappedEntry = wrapEntry(entry)
  t.looseEqual(wrappedEntry.toPlainObject(), entry)
  t.end()
})

test('Entry collection is wrapped', t => {
  const wrappedEntry = wrapEntryCollection({
    total: 1,
    skip: 0,
    limit: 100,
    items: [
      entry
    ]
  })
  t.looseEqual(wrappedEntry.toPlainObject(), entry)
  t.end()
})<commit_msg>test(unit): Fix entry wrapper tests<commit_after>/* @flow */
import test from 'tape'
import {assign} from 'lodash/object'
import {cloneDeep} from 'lodash/lang'
import {sysMock, linkMock} from '../mocks'

import {wrapEntry, wrapEntryCollection} from '../../../lib/entities/entry'

const entry = {
  sys: assign(cloneDeep(sysMock), {
    type: 'Entry',
    contentType: assign(cloneDeep(linkMock), {linkType: 'ContentType'}),
    locale: 'locale'
  }),
  fields: {
    field1: 'str'
  }
}

test('Entry is wrapped', t => {
  const wrappedEntry = wrapEntry(entry)
  t.looseEqual(wrappedEntry.toPlainObject(), entry)
  t.end()
})

test('Entry collection is wrapped', t => {
  const entryCollection = {
    total: 1,
    skip: 0,
    limit: 100,
    items: [
      entry
    ]
  }
  const wrappedEntry = wrapEntryCollection(entryCollection)
  t.looseEqual(wrappedEntry.toPlainObject(), entryCollection)
  t.end()
})
{'fraction_non_alphanumeric': 0.15837621497998858, 'fraction_numerical': 0.00686106346483705, 'mean_word_length': 3.755434782608696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7128393', 'n_tokens_mistral': 605, 'n_tokens_neox': 594, 'n_words': 142}