text: import updatePath from './updatePath'
  
  describe('updatePath', () => {
    test('update an object using a single existing path', () => {
      const collection = {
        foo: 'bar',
      }
      const result = updatePath(['foo'], () => 'baz', collection)
      expect(result).toEqual({
        foo: 'baz',
      })
      expect(result).not.toBe(collection)
    })
  
    test('set to an object using a Symbol', () => {
      const collection = {}
      const symFoo = Symbol('foo')
      expect(updatePath([symFoo], () => 'baz', collection)).toEqual({
        [symFoo]: 'baz',
      })
    })
  
    test('set to an object using a Symbol then a prop', () => {
      const collection = {}
      const symFoo = Symbol('foo')
      const result1 = updatePath([symFoo], () => 'baz', collection)
      expect(result1).toEqual({
        [symFoo]: 'baz',
      })
      expect(collection).toEqual({})
  
      const result2 = updatePath(['test'], () => 'value', result1)
      expect(result2).toEqual({
        [symFoo]: 'baz',
        test: 'value',
      })
      expect(result1).toEqual({
        [symFoo]: 'baz',
      })
      expect(collection).toEqual({})
    })
  
    test('set to an object using a single existing key with dots', () => {
      const collection = {
        'foo.bar': 'baz',
      }
      expect(updatePath(['foo.bar'], () => 'fum', collection)).toEqual({
        'foo.bar': 'fum',
      })
    })
  
    test('set to an array using a single existing index', () => {
      const collection = ['bar']
      expect(updatePath([0], () => 'baz', collection)).toEqual(['baz'])
    })
  
    test('set to a Map using a single existing key', () => {
      const collection = new Map([['foo', 'bar']])
      expect([...updatePath(['foo'], () => 'baz', collection).entries()]).toEqual([['foo', 'baz']])
    })
  
    test('set to an object using a single non existing key', () => {
      const collection = {
        foo: 'bar',
      }
      expect(updatePath(['bim'], () => 'bop', collection)).toEqual({
        bim: 'bop',
        foo: 'bar',
      })
    })
  
    test('set to an array using a single non existing index', () => {
      const collection = ['bar']
      expect(updatePath([1], () => 'bop', collection)).toEqual(['bar', 'bop'])
    })
  
    test('set to a Map using a single non existing key', () => {
      const collection = new Map([['foo', 'bar']])
      expect([...updatePath(['bim'], () => 'bop', collection).entries()]).toEqual([
        ['foo', 'bar'],
        ['bim', 'bop'],
      ])
    })
  
    test('dispatches to the updateIn method of collection', () => {
      const collection = {
        updateIn(path, updater) {
          return {
            ...this,
            values: {
              ...this.values,
              [path[0]]: updater(this.values[path[0]]),
            },
          }
        },
        values: {
          foo: 'bar',
        },
      }
  
      expect(updatePath(['bim'], () => 'bop', collection).values).toEqual({
        bim: 'bop',
        foo: 'bar',
      })
    })
  
    test('automatically upgrades to async when the collection is a Promise', async () => {
      const collection = Promise.resolve({
        foo: 'bar',
      })
      const result = updatePath(['foo'], () => 'baz', collection)
      expect(result).toBeInstanceOf(Promise)
      expect(await result).toEqual({
        foo: 'baz',
      })
    })
  
    test('automatically upgrades to async when the key is a Promise', async () => {
      const key = Promise.resolve('foo')
      const result = updatePath([key], () => 'baz', {
        foo: 'bar',
      })
      expect(result).toBeInstanceOf(Promise)
      expect(await result).toEqual({
        foo: 'baz',
      })
    })
  
    test('does NOT automatically upgrades to async when the value is a Promise', async () => {
      const value = Promise.resolve('baz')
      const result = updatePath(['foo'], () => value, {
        foo: 'bar',
      })
      expect(result).toEqual({
        foo: Promise.resolve('baz'),
      })
    })
  })
  