Skip to content

Commit

Permalink
Merge pull request atom#515 from atom/failing-build-master
Browse files Browse the repository at this point in the history
Failing build on Dev channel
  • Loading branch information
darangi authored Mar 20, 2020
2 parents 798ada4 + 3cb2137 commit 77c2453
Showing 1 changed file with 54 additions and 3 deletions.
57 changes: 54 additions & 3 deletions test/editor-binding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fs = require('fs')
const path = require('path')
const SAMPLE_TEXT = fs.readFileSync(path.join(__dirname, 'fixtures', 'sample.js'), 'utf8')
const {TextEditor, TextBuffer, Range} = require('atom')
const {Point} = TextBuffer
const EditorBinding = require('../lib/editor-binding')
const {buildAtomEnvironment, destroyAtomEnvironments} = require('./helpers/atom-environments')
const {loadPackageStyleSheets} = require('./helpers/ui-helpers')
Expand All @@ -16,6 +17,15 @@ const {FollowState} = require('@atom/teletype-client')
const FakeBufferProxy = require('./helpers/fake-buffer-proxy')
const BufferBinding = require('../lib/buffer-binding')

/*
We are currently checking if teletype is trying to build against the dev version of atom which uses electron 5.
This is because there is a slight change in electron 5s API and some of the assertions in this tests need to be
changed. The stable and beta version of atom still uses electron 4 inorder to support both electron
versions, the assertions need to be made accordingly. In the future when stable and beta start compiling against
electron 5, these assertions will be simplified.
*/
const isDevBuild = atom.getAppName().toLowerCase().indexOf('atom dev') > -1

suite('EditorBinding', function () {
if (process.env.CI) this.timeout(process.env.TEST_TIMEOUT_IN_MS)

Expand Down Expand Up @@ -94,8 +104,23 @@ suite('EditorBinding', function () {
1: {range: {start: {row: 3, column: 0}, end: {row: 4, column: 2}}},
2: {range: {start: {row: 5, column: 0}, end: {row: 6, column: 0}}, reversed: true}
})

const cursorDecoratedRanges = getCursorDecoratedRanges(editor)

if (isDevBuild) {
return assert.deepEqual(
cursorDecoratedRanges,
[
{tail: Point(10, 0), head: Point(11, 4)},
{tail: Point(20, 5), head: Point(20, 0)},
{tail: Point(3, 0), head: Point(4, 2)},
{tail: Point(6, 0), head: Point(5, 0)}
]
)
}

assert.deepEqual(
getCursorDecoratedRanges(editor),
cursorDecoratedRanges,
[
{tail: {row: 3, column: 0}, head: {row: 4, column: 2}},
{tail: {row: 6, column: 0}, head: {row: 5, column: 0}},
Expand Down Expand Up @@ -135,8 +160,21 @@ suite('EditorBinding', function () {
binding.updateSelectionsForSiteId(2, {
1: {range: {start: {row: 3, column: 0}, end: {row: 4, column: 2}}}
})

const cursorDecoratedRanges = getCursorDecoratedRanges(editor)

if (isDevBuild) {
return assert.deepEqual(
cursorDecoratedRanges,
[
{tail: Point(10, 0), head: Point(11, 4)},
{tail: Point(20, 0), head: Point(20, 5)},
{tail: Point(3, 0), head: Point(4, 2)}
]
)
}
assert.deepEqual(
getCursorDecoratedRanges(editor),
cursorDecoratedRanges,
[
{tail: {row: 3, column: 0}, head: {row: 4, column: 2}},
{tail: {row: 10, column: 0}, head: {row: 11, column: 4}},
Expand Down Expand Up @@ -225,8 +263,21 @@ suite('EditorBinding', function () {
editor.setSelectedBufferRange([[0, 0], [0, 5]])
editor.getBuffer().setTextInRange([[0, 0], [0, 5]], '', {undo: 'skip'})
editor.getBuffer().setTextInRange([[0, 0], [0, 0]], '123', {undo: 'skip'})

const cursorDecoratedRanges = getCursorDecoratedRanges(editor)

if (isDevBuild) {
return assert.deepEqual(
cursorDecoratedRanges,
[
{tail: Point(0, 3), head: Point(0, 3)},
{tail: Point(0, 6), head: Point(0, 6)}
]
)
}

assert.deepEqual(
getCursorDecoratedRanges(editor),
cursorDecoratedRanges,
[
{tail: {row: 0, column: 6}, head: {row: 0, column: 6}},
{tail: {row: 0, column: 3}, head: {row: 0, column: 3}}
Expand Down

0 comments on commit 77c2453

Please sign in to comment.