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

Code before:
        )

        runs(() =>
          expect(
            workspace.getActiveTextEditor().getCursorBufferPosition()
          ).toEqual([2, 0])
        )

        waitsForPromise(() =>
          workspace.open('a', {
            initialLine: Infinity,
            initialColumn: Infinity
          })
        )

        runs(() =>
          expect(
            workspace.getActiveTextEditor().getCursorBufferPosition()
          ).toEqual([2, 11])
        )
      })

      it('unfolds the fold containing the line', () => {
        let editor

        waitsForPromise(() =>
          workspace.open('../sample-with-many-folds.js')
        )

        runs(() => {
          editor = workspace.getActiveTextEditor()
          editor.foldBufferRow(2)
          expect(editor.isFoldedAtBufferRow(2)).toBe(true)
          expect(editor.isFoldedAtBufferRow(3)).toBe(true)
        })

        waitsForPromise(() =>
          workspace.open('../sample-with-many-folds.js', { initialLine: 2 })
        )

        runs(() => {
          expect(editor.isFoldedAtBufferRow(2)).toBe(false)
          expect(editor.isFoldedAtBufferRow(3)).toBe(false)
        })
      })
    })

    describe('when the file size is over the limit defined in `core.warnOnLargeFileLimit`', () => {
      const shouldPromptForFileOfSize = async (size, shouldPrompt) => {
        spyOn(fs, 'getSizeSync').andReturn(size * 1048577)


Review comment (suggestion):
A small improvement: you can make the spec function `async` to be able to use `await` on the `workspace.open()` function calls and then get rid of all the `runs()` and `waitsForPromise()` calls.

Code after:
        )

        runs(() =>
          expect(
            workspace.getActiveTextEditor().getCursorBufferPosition()
          ).toEqual([2, 0])
        )

        waitsForPromise(() =>
          workspace.open('a', {
            initialLine: Infinity,
            initialColumn: Infinity
          })
        )

        runs(() =>
          expect(
            workspace.getActiveTextEditor().getCursorBufferPosition()
          ).toEqual([2, 11])
        )
      })

      it('unfolds the fold containing the line', async () => {
        let editor

        await workspace.open('../sample-with-many-folds.js')
        editor = workspace.getActiveTextEditor()
        editor.foldBufferRow(2)
        expect(editor.isFoldedAtBufferRow(2)).toBe(true)
        expect(editor.isFoldedAtBufferRow(3)).toBe(true)

        await workspace.open('../sample-with-many-folds.js', { initialLine: 2 })
        expect(editor.isFoldedAtBufferRow(2)).toBe(false)
        expect(editor.isFoldedAtBufferRow(3)).toBe(false)
      })
    })

    describe('when the file size is over the limit defined in `core.warnOnLargeFileLimit`', () => {
      const shouldPromptForFileOfSize = async (size, shouldPrompt) => {
        spyOn(fs, 'getSizeSync').andReturn(size * 1048577)

        let selectedButtonIndex = 1 // cancel
        atom.applicationDelegate.confirm.andCallFake((options, callback) =>
          callback(selectedButtonIndex)
        )

        let editor = await workspace.open('sample.js')
        if (shouldPrompt) {
          expect(editor).toBeUndefined()
          expect(atom.applicationDelegate.confirm).toHaveBeenCalled()