Repository: atom/atom
File: spec/config-spec.js (JavaScript)

Code before:
      expect(atom.config.get('foo.qux')).toBe('boo')
      expect(atom.config.get('do.ray')).toBeUndefined()

      advanceClock(100)
      expect(savedSettings.length).toBe(0)

      atom.config.resetUserSettings({
        '*': {
          foo: {
            bar: 'baz'
          },
          do: {
            ray: 'me'
          }
        }
      })

      advanceClock(100)
      expect(savedSettings.length).toBe(1)
      expect(atom.config.get('foo.bar')).toBeUndefined()
      expect(atom.config.get('foo.qux')).toBe('boo')
      expect(atom.config.get('do.ray')).toBe('me')
    })
  })

  describe('project specific configs', () => {
    describe('config.resetProjectSettings', () => {
      it('gracefully handles invalid config objects', () => {
        atom.config.resetProjectSettings({})
        expect(atom.config.get('foo.bar')).toBeUndefined()
      })
    })

    describe('config.get', () => {
      const dummyPath = '/Users/dummy/path.json'
      describe('project configs', () => {
        it('returns a deep clone of the property value', () => {
          atom.config.resetProjectSettings({'*': {'value': {array: [1, {b: 2}, 3]}}}, dummyPath)
          const retrievedValue = atom.config.get('value')
          retrievedValue.array[0] = 4
          retrievedValue.array[1].b = 2.1
          expect(atom.config.get('value')).toEqual({array: [1, {b: 2}, 3]})
        })

        it('should properly get project configs', () => {
          atom.config.resetProjectSettings({'*': {'foo': 'wei'}}, dummyPath)
          expect(atom.config.get('foo')).toBe('wei')
          atom.config.resetProjectSettings({'*': {'foo': {'bar': 'baz'}}}, dummyPath)
          expect(atom.config.get('foo.bar')).toBe('baz')
        })


Review comment (suggestion):
Let the minor nitpicks begin! I have a few wording suggestions:

* I think `project specific configs` should be `project-specific settings` (here as well as in later `it/describe` strings)
* Can you drop the 'should' from the test descriptions (e.g. `should get` becomes `gets`)

Code after:
      expect(atom.config.get('foo.qux')).toBe('boo')
      expect(atom.config.get('do.ray')).toBeUndefined()

      advanceClock(100)
      expect(savedSettings.length).toBe(0)

      atom.config.resetUserSettings({
        '*': {
          foo: {
            bar: 'baz'
          },
          do: {
            ray: 'me'
          }
        }
      })

      advanceClock(100)
      expect(savedSettings.length).toBe(1)
      expect(atom.config.get('foo.bar')).toBeUndefined()
      expect(atom.config.get('foo.qux')).toBe('boo')
      expect(atom.config.get('do.ray')).toBe('me')
    })
  })

  describe('project specific settings', () => {
    describe('config.resetProjectSettings', () => {
      it('gracefully handles invalid config objects', () => {
        atom.config.resetProjectSettings({})
        expect(atom.config.get('foo.bar')).toBeUndefined()
      })
    })

    describe('config.get', () => {
      const dummyPath = '/Users/dummy/path.json'
      describe('project settings', () => {
        it('returns a deep clone of the property value', () => {
          atom.config.resetProjectSettings({'*': {'value': {array: [1, {b: 2}, 3]}}}, dummyPath)
          const retrievedValue = atom.config.get('value')
          retrievedValue.array[0] = 4
          retrievedValue.array[1].b = 2.1
          expect(atom.config.get('value')).toEqual({array: [1, {b: 2}, 3]})
        })

        it('properly gets project settings', () => {
          atom.config.resetProjectSettings({'*': {'foo': 'wei'}}, dummyPath)
          expect(atom.config.get('foo')).toBe('wei')
          atom.config.resetProjectSettings({'*': {'foo': {'bar': 'baz'}}}, dummyPath)
          expect(atom.config.get('foo.bar')).toBe('baz')
        })