Skip to content

Commit

Permalink
🆕 Add specs for validateEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
steelbrain committed Feb 11, 2016
1 parent 465c50a commit 1e73922
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions spec/helper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as fs from 'fs'
import * as path from 'path'
import { waitsForAsync, waitsForAsyncRejection } from './spec-helpers'
const helpersOfHelpers = require('../src/helpers')
const helpers = require('../src/index')

const bothFile = path.join(__dirname, 'fixtures', 'both.js')
Expand Down Expand Up @@ -362,4 +363,41 @@ describe('linter helpers', function () {
)
)
})
describe('validateEditor', function () {
it('works if there\'s atom.workspace.isTextEditor', function () {
waitsForAsync(async function () {
await atom.workspace.open(somethingFile)
const textEditor = atom.workspace.getActiveTextEditor()
expect(function () {
helpersOfHelpers.validateEditor(textEditor)
}).not.toThrow()
expect(function () {
helpersOfHelpers.validateEditor(null)
}).toThrow()
expect(function () {
helpersOfHelpers.validateEditor(false)
}).toThrow()
})
})
it('works if there isnt atom.workspace.isTextEditor', function () {
waitsForAsync(async function () {
const _ = atom.workspace.isTextEditor
atom.workspace.isTextEditor = null

await atom.workspace.open(somethingFile)
const textEditor = atom.workspace.getActiveTextEditor()
expect(function () {
helpersOfHelpers.validateEditor(textEditor)
}).not.toThrow()
expect(function () {
helpersOfHelpers.validateEditor(null)
}).toThrow()
expect(function () {
helpersOfHelpers.validateEditor(false)
}).toThrow()

atom.workspace.isTextEditor = _
})
})
})
})

0 comments on commit 1e73922

Please sign in to comment.