diff --git a/spec/text-editor-spec.js b/spec/text-editor-spec.js index 1980d2e36..f0a55b5c2 100644 --- a/spec/text-editor-spec.js +++ b/spec/text-editor-spec.js @@ -7511,12 +7511,12 @@ describe('TextEditor', () => { editor = await atom.workspace.open('sample.js', {autoIndent: false}) editor.foldAllAtIndentLevel(0) - expect(editor.lineTextForScreenRow(0)).toBe(`var quicksort = function () {${editor.displayLayer.foldCharacter}`) + expect(editor.lineTextForScreenRow(0)).toBe(`var quicksort = function () {${editor.displayLayer.foldCharacter}};`) expect(editor.getLastScreenRow()).toBe(0) editor.foldAllAtIndentLevel(1) expect(editor.lineTextForScreenRow(0)).toBe('var quicksort = function () {') - expect(editor.lineTextForScreenRow(1)).toBe(` var sort = function(items) {${editor.displayLayer.foldCharacter}`) + expect(editor.lineTextForScreenRow(1)).toBe(` var sort = function(items) {${editor.displayLayer.foldCharacter}};`) expect(editor.getLastScreenRow()).toBe(4) editor.foldAllAtIndentLevel(2) @@ -7526,19 +7526,6 @@ describe('TextEditor', () => { expect(editor.getLastScreenRow()).toBe(9) }) - it('folds every foldable range at a given indentLevel', async () => { - editor = await atom.workspace.open('sample-with-comments.js', {autoIndent: false}) - - editor.foldAllAtIndentLevel(2) - const folds = editor.unfoldAll() - expect(folds.length).toBe(5) - expect([folds[0].start.row, folds[0].end.row]).toEqual([6, 8]) - expect([folds[1].start.row, folds[1].end.row]).toEqual([11, 16]) - expect([folds[2].start.row, folds[2].end.row]).toEqual([17, 20]) - expect([folds[3].start.row, folds[3].end.row]).toEqual([21, 22]) - expect([folds[4].start.row, folds[4].end.row]).toEqual([24, 25]) - }) - it('does not fold anything but the indentLevel', async () => { editor = await atom.workspace.open('sample-with-comments.js', {autoIndent: false}) @@ -7548,36 +7535,6 @@ describe('TextEditor', () => { expect([folds[0].start.row, folds[0].end.row]).toEqual([0, 30]) }) }) - - describe('.isFoldableAtBufferRow(bufferRow)', () => { - it('returns true if the line starts a multi-line comment', async () => { - editor = await atom.workspace.open('sample-with-comments.js') - - expect(editor.isFoldableAtBufferRow(1)).toBe(true) - expect(editor.isFoldableAtBufferRow(6)).toBe(true) - expect(editor.isFoldableAtBufferRow(8)).toBe(false) - expect(editor.isFoldableAtBufferRow(11)).toBe(true) - expect(editor.isFoldableAtBufferRow(15)).toBe(false) - expect(editor.isFoldableAtBufferRow(17)).toBe(true) - expect(editor.isFoldableAtBufferRow(21)).toBe(true) - expect(editor.isFoldableAtBufferRow(24)).toBe(true) - expect(editor.isFoldableAtBufferRow(28)).toBe(false) - }) - - it('returns true for lines that end with a comment and are followed by an indented line', async () => { - editor = await atom.workspace.open('sample-with-comments.js') - - expect(editor.isFoldableAtBufferRow(5)).toBe(true) - }) - - it("does not return true for a line in the middle of a comment that's followed by an indented line", async () => { - editor = await atom.workspace.open('sample-with-comments.js') - - expect(editor.isFoldableAtBufferRow(7)).toBe(false) - editor.buffer.insert([8, 0], ' ') - expect(editor.isFoldableAtBufferRow(7)).toBe(false) - }) - }) }) }) diff --git a/spec/text-mate-language-mode-spec.js b/spec/text-mate-language-mode-spec.js index 632a56aef..47b79af2d 100644 --- a/spec/text-mate-language-mode-spec.js +++ b/spec/text-mate-language-mode-spec.js @@ -786,6 +786,36 @@ describe('TextMateLanguageMode', () => { expect(languageMode.isFoldableAtRow(7)).toBe(false) expect(languageMode.isFoldableAtRow(8)).toBe(false) }) + + it('returns true if the line starts a multi-line comment', async () => { + editor = await atom.workspace.open('sample-with-comments.js') + fullyTokenize(editor.getBuffer().getLanguageMode()) + + expect(editor.isFoldableAtBufferRow(1)).toBe(true) + expect(editor.isFoldableAtBufferRow(6)).toBe(true) + expect(editor.isFoldableAtBufferRow(8)).toBe(false) + expect(editor.isFoldableAtBufferRow(11)).toBe(true) + expect(editor.isFoldableAtBufferRow(15)).toBe(false) + expect(editor.isFoldableAtBufferRow(17)).toBe(true) + expect(editor.isFoldableAtBufferRow(21)).toBe(true) + expect(editor.isFoldableAtBufferRow(24)).toBe(true) + expect(editor.isFoldableAtBufferRow(28)).toBe(false) + }) + + it('returns true for lines that end with a comment and are followed by an indented line', async () => { + editor = await atom.workspace.open('sample-with-comments.js') + + expect(editor.isFoldableAtBufferRow(5)).toBe(true) + }) + + it("does not return true for a line in the middle of a comment that's followed by an indented line", async () => { + editor = await atom.workspace.open('sample-with-comments.js') + fullyTokenize(editor.getBuffer().getLanguageMode()) + + expect(editor.isFoldableAtBufferRow(7)).toBe(false) + editor.buffer.insert([8, 0], ' ') + expect(editor.isFoldableAtBufferRow(7)).toBe(false) + }) }) describe('.getFoldableRangesAtIndentLevel', () => { @@ -848,6 +878,20 @@ describe('TextMateLanguageMode', () => { } `) }) + + it('folds every foldable range at a given indentLevel', async () => { + editor = await atom.workspace.open('sample-with-comments.js') + fullyTokenize(editor.getBuffer().getLanguageMode()) + + editor.foldAllAtIndentLevel(2) + const folds = editor.unfoldAll() + expect(folds.length).toBe(5) + expect([folds[0].start.row, folds[0].end.row]).toEqual([6, 8]) + expect([folds[1].start.row, folds[1].end.row]).toEqual([11, 16]) + expect([folds[2].start.row, folds[2].end.row]).toEqual([17, 20]) + expect([folds[3].start.row, folds[3].end.row]).toEqual([21, 22]) + expect([folds[4].start.row, folds[4].end.row]).toEqual([24, 25]) + }) }) describe('.getFoldableRanges', () => {