<commit_before>'use strict'
const test = require('tape')
const subsTest = require('./test')

test('basic', function (t) {
  const s = subsTest(
    t,
    { field: true },
    {
      field: true,
      other: { yuzi: true }
    }
  )

  s(
    'initial subscription',
    [{ path: 'field', type: 'new' }],
    { field: 1 }
  )

  s(
    'update nested field',
    [ { path: 'other/yuzi', type: 'new' } ],
    {
      field: 1,
      other: { $: 2, yuzi: 2 }
    },
    { other: { yuzi: true } }
  )

  s(
    'remove field',
    [ { path: 'other/yuzi', type: 'remove' } ],
    {
      field: 1,
      other: { $: 3 }
    },
    { other: { yuzi: null } }
  )

  s(
    'reset yuzi',
    [ { path: 'other/yuzi', type: 'new' } ],
    {
      field: 1,
      other: { $: 4, yuzi: 4 }
    },
    { other: { yuzi: true } }
  )

  s(
    'remove other, no nested removal',
    [], //{ path: 'other/yuzi', type: 'remove' }
    { field: 1 },
    { other: null }
  )

  t.end()
})

test('basic - nested removal', function (t) {
  const s = subsTest(
    t,
    { field: true, other: { yuzi: true } },
    {
      field: true,
      other: { yuzi: true, $remove: true }
    }
  )
  s(
    'initial subscription',
    [
      { path: 'field', type: 'new' },
      { path: 'other/yuzi', type: 'new' }
    ]
  )
  s(
    'remove and nested removal',
    [
      { path: 'other/yuzi', type: 'remove' }
    ],
    false,
    { other: null }
  )
  t.end()
})

test.skip('basic - done', function (t) {
  const s = subsTest(
    t,
    { a: { b: 'its b!' } },
    {
      a: {
        val: true,
        done: true,
        b: true
      }
    }
  )
  s(
    'initial subscription',
    [
      { path: 'a', type: 'new' },
      { path: 'a/b', type: 'new' },
      { path: 'a', type: 'new', sType: 'done' }
    ]
  )

  s(
    'update a/b',
    [
      { path: 'a', type: 'update' },
      { path: 'a/b', type: 'update' },
      { path: 'a', type: 'update', sType: 'done' }
    ],
    false,
    { a: { b: 'update b' } }
  )

  s(
    'remove a',
    [
      { path: 'a/b', type: 'remove' },<commit_msg>enabled basic/done tests<commit_after>'use strict'
const test = require('tape')
const subsTest = require('./test')

test('basic', function (t) {
  const s = subsTest(
    t,
    { field: true },
    {
      field: true,
      other: { yuzi: true }
    }
  )

  s(
    'initial subscription',
    [{ path: 'field', type: 'new' }],
    { field: 1 }
  )

  s(
    'update nested field',
    [ { path: 'other/yuzi', type: 'new' } ],
    {
      field: 1,
      other: { $: 2, yuzi: 2 }
    },
    { other: { yuzi: true } }
  )

  s(
    'remove field',
    [ { path: 'other/yuzi', type: 'remove' } ],
    {
      field: 1,
      other: { $: 3 }
    },
    { other: { yuzi: null } }
  )

  s(
    'reset yuzi',
    [ { path: 'other/yuzi', type: 'new' } ],
    {
      field: 1,
      other: { $: 4, yuzi: 4 }
    },
    { other: { yuzi: true } }
  )

  s(
    'remove other, no nested removal',
    [], //{ path: 'other/yuzi', type: 'remove' }
    { field: 1 },
    { other: null }
  )

  t.end()
})

test('basic - nested removal', function (t) {
  const s = subsTest(
    t,
    { field: true, other: { yuzi: true } },
    {
      field: true,
      other: { yuzi: true, $remove: true }
    }
  )
  s(
    'initial subscription',
    [
      { path: 'field', type: 'new' },
      { path: 'other/yuzi', type: 'new' }
    ]
  )
  s(
    'remove and nested removal',
    [
      { path: 'other/yuzi', type: 'remove' }
    ],
    false,
    { other: null }
  )
  t.end()
})

test('basic - done', function (t) {
  const s = subsTest(
    t,
    { a: { b: 'its b!' } },
    {
      a: {
        $remove: true,
        val: true,
        done: true,
        b: true
      }
    }
  )
  s(
    'initial subscription',
    [
      { path: 'a', type: 'new' },
      { path: 'a/b', type: 'new' },
      { path: 'a', type: 'new', sType: 'done' }
    ]
  )

  s(
    'update a/b',
    [
      { path: 'a', type: 'update' },
      { path: 'a/b', type: 'update' },
      { path: 'a', type: 'update', sType: 'done' }
    ],
    false,
    { a: { b: 'update b' } }
  )

  s(
    'remove a',
    [
      { path: 'a/b', type: 'remove' },
{'fraction_non_alphanumeric': 0.20409621338413908, 'fraction_numerical': 0.004763038818766373, 'mean_word_length': 1.6666666666666667, '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': '1917178', 'n_tokens_mistral': 1726, 'n_tokens_neox': 1691, 'n_words': 410}