<commit_before>import test from 'ava'
import sanitiseObject from './index'

test('should sanitise keys', t => {
  const input = {
    username: 'batou',
    password: '<PASSWORD>',
    friend: 'tachikoma'
  }
  const output = {
    username: 'batou'
  }
  sanitiseObject(input, ['password', 'friend'])
  t.deepEqual(input, output)
})

test('should use defaults', t => {
  const input = {
    username: 'batou',
    password: '<PASSWORD>'
  }
  const output = {
    username: 'batou'
  }
  sanitiseObject(input)
  t.deepEqual(input, output)
})

test('should sanitise nested objects', t => {
  const input = {
    username: 'batou',
    password: '<PASSWORD>',
    friend: {
      name: 'tachikoma',
      password: '<PASSWORD>'
    }
  }
  const output = {
    username: 'batou',
    friend: {
      name: 'tachikoma'
    }
  }
  sanitiseObject(input, ['password'])
  t.deepEqual(input, output)
})

test('should sanitise nested arrays', t => {
  const input = {
    username: 'batou',
    password: '<PASSWORD>',
    friends: [{
      name: 'tachikoma',
      password: '<PASSWORD>'
    }]
  }
  const output = {
    username: 'batou',
    friends: [{
      name: 'tachikoma'
    }]
  }
  sanitiseObject(input, ['password'])
  t.deepEqual(input, output)
})

test('should do partial matches', t => {
  const input = {
    username: 'batou',
    apikey: 'major'
  }
  const output = {
    username: 'batou'
  }
  sanitiseObject(input, ['key'])
  t.deepEqual(input, output)
})

test('should be case insensitive', t => {
  const input = {
    username: 'batou',
    pAsSwOrD: 'major'
  }
  const output = {
    username: 'batou'
  }
  sanitiseObject(input, ['password'])
  t.deepEqual(input, output)
})<commit_msg>tests: do not rely on the object reference<commit_after>import test from 'ava'
import sanitiseObject from './index'

test('should sanitise keys', t => {
  const input = {
    username: 'batou',
    password: '<PASSWORD>',
    friend: 'tachikoma'
  }
  const output = {
    username: 'batou'
  }
  t.deepEqual(sanitiseObject(input, ['password', 'friend']), output)
})

test('should use defaults', t => {
  const input = {
    username: 'batou',
    password: '<PASSWORD>'
  }
  const output = {
    username: 'batou'
  }
  t.deepEqual(sanitiseObject(input), output)
})

test('should sanitise nested objects', t => {
  const input = {
    username: 'batou',
    password: '<PASSWORD>',
    friend: {
      name: 'tachikoma',
      password: '<PASSWORD>'
    }
  }
  const output = {
    username: 'batou',
    friend: {
      name: 'tachikoma'
    }
  }
  t.deepEqual(sanitiseObject(input, ['password']), output)
})

test('should sanitise nested arrays', t => {
  const input = {
    username: 'batou',
    password: '<PASSWORD>',
    friends: [{
      name: 'tachikoma',
      password: '<PASSWORD>'
    }]
  }
  const output = {
    username: 'batou',
    friends: [{
      name: 'tachikoma'
    }]
  }
  t.deepEqual(sanitiseObject(input, ['password']), output)
})

test('should do partial matches', t => {
  const input = {
    username: 'batou',
    apikey: 'major'
  }
  const output = {
    username: 'batou'
  }
  t.deepEqual(sanitiseObject(input, ['key']), output)
})

test('should be case insensitive', t => {
  const input = {
    username: 'batou',
    pAsSwOrD: 'major'
  }
  const output = {
    username: 'batou'
  }
  t.deepEqual(sanitiseObject(input, ['password']), output)
})
{'fraction_non_alphanumeric': 0.16446013533392173, 'fraction_numerical': 0.0, 'mean_word_length': 3.009433962264151, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, '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': '2310045', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1193, 'n_words': 277}