Move whitespace trimming integration spec to main process tests

This commit is contained in:
Nathan Sobo
2016-08-11 14:43:23 -06:00
parent f80c800347
commit 15bb92f35e
2 changed files with 23 additions and 14 deletions

View File

@@ -40,17 +40,6 @@ describe "Starting Atom", ->
.then ({value}) -> expect(value).toBe "Hello!"
.dispatchCommand("editor:delete-line")
it "removes all trailing whitespace and colons from the specified path", ->
filePath = path.join(tempDirPath, "new-file")
runAtom ["#{filePath}: "], {ATOM_HOME: atomHome}, (client) ->
client
.waitForPaneItemCount(1, 1000)
.waitForExist("atom-text-editor", 5000)
.then (exists) -> expect(exists).toBe true
.execute -> atom.workspace.getActiveTextEditor().getPath()
.then ({value}) -> expect(value).toBe filePath
describe "when there is already a window open", ->
it "reuses that window when opening files, but not when opening directories", ->
tempFilePath = path.join(temp.mkdirSync("a-third-dir"), "a-file")

View File

@@ -15,7 +15,7 @@ describe('AtomApplication', function () {
beforeEach(function () {
originalAtomHome = process.env.ATOM_HOME
process.env.ATOM_HOME = temp.mkdirSync('atom-home')
process.env.ATOM_HOME = makeTempDir('atom-home')
// Symlinking the compile cache into the temporary home dir makes the windows load much faster
fs.symlinkSync(path.join(originalAtomHome, 'compile-cache'), path.join(process.env.ATOM_HOME, 'compile-cache'))
atomApplicationsToDestroy = []
@@ -32,7 +32,7 @@ describe('AtomApplication', function () {
this.timeout(20000)
it('can open to a specific line number of a file', async function () {
const filePath = path.join(temp.mkdirSync(), 'new-file')
const filePath = path.join(makeTempDir(), 'new-file')
fs.writeFileSync(filePath, '1\n2\n3\n4\n')
const atomApplication = buildAtomApplication()
@@ -49,7 +49,7 @@ describe('AtomApplication', function () {
})
it('can open to a specific line and column of a file', async function () {
const filePath = path.join(temp.mkdirSync(), 'new-file')
const filePath = path.join(makeTempDir(), 'new-file')
fs.writeFileSync(filePath, '1\n2\n3\n4\n')
const atomApplication = buildAtomApplication()
@@ -65,6 +65,23 @@ describe('AtomApplication', function () {
assert.deepEqual(cursorPosition, {row: 1, column: 1})
})
it('removes all trailing whitespace and colons from the specified path', async function () {
let filePath = path.join(makeTempDir(), 'new-file')
fs.writeFileSync(filePath, '1\n2\n3\n4\n')
const atomApplication = buildAtomApplication()
const window = atomApplication.openWithOptions(parseCommandLine([filePath + ':: ']))
await window.loadedPromise
const openedPath = await evalInWebContents(window.browserWindow.webContents, function (sendBackToMainProcess) {
atom.workspace.onDidChangeActivePaneItem(function (textEditor) {
sendBackToMainProcess(textEditor.getPath())
})
})
assert.equal(openedPath, filePath)
})
it('positions new windows at an offset distance from the previous window', async function () {
const atomApplication = buildAtomApplication()
@@ -90,6 +107,9 @@ describe('AtomApplication', function () {
atomApplicationsToDestroy.push(atomApplication)
return atomApplication
}
function makeTempDir (name) {
return fs.realpathSync(temp.mkdirSync(name))
}
let channelIdCounter = 0
function evalInWebContents (webContents, source) {