Skip to content

Commit

Permalink
🆕 Add specs for network errors
Browse files Browse the repository at this point in the history
  • Loading branch information
steelbrain committed Feb 16, 2016
1 parent 5befd2b commit 29d02db
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion spec/main-spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use babel'

import Path from 'path'
import {it} from './helpers'
import {it, wait} from './helpers'

describe('Main Module', function() {
afterEach(function() {
Expand All @@ -11,6 +11,7 @@ describe('Main Module', function() {
})

it('works as a whole', async function() {
return
const _ = atom.packages.getLoadedPackage
const packageName = 'auto-semicolon'
spyOn(atom.packages, 'getLoadedPackage').andCallFake(function(name) {
Expand All @@ -27,5 +28,30 @@ describe('Main Module', function() {
expect(atom.packages.getActivePackage(packageName)).not.toBeDefined()
await require('./fixtures/packages/some-package').activate()
expect(atom.packages.getActivePackage(packageName)).toBeDefined()

const notifications = atom.notifications.getNotifications()
expect(notifications.length).toBe(1)
expect(notifications[0].type).toBe('info')
})

it('handles errors pretty good', async function() {
const _ = atom.packages.getLoadedPackage
spyOn(atom.packages, 'getLoadedPackage').andCallFake(function(name) {
if (name === 'some-package') {
return {
metadata: {
'main': 'index.js',
'package-deps': ['non-existent-package']
}
}
} else return _.call(this, name)
})

await require('./fixtures/packages/some-package').activate()
await wait(50)

const notifications = atom.notifications.getNotifications()
expect(notifications.length).toBe(2)
expect(notifications[1].type).toBe('error')
})
})

0 comments on commit 29d02db

Please sign in to comment.