       vcode: "abcdefg"
       label: "hijklmnop"
     ctrl.addKey()
-    console.log 'Not yet applied.'
     scope.$apply()
-    console.log 'Applied.'
     expect(ctrl.alerts.length).toEqual 1
     ctrl.closeAlert(0)
     expect(ctrl.alerts.length).toEqual 0

              data:
                status: 'OK'
                characters: []
          deferred.promise

      spyOn Server, 'getLoginStatus'

    scope.$apply()
    expect(ctrl.authenticated).toBeFalsy()
    expect(ctrl.apikeys.length).toEqual 0

  it 'should handle API key refresh', () ->
    scope.$apply()
    expect(ctrl.apikeys[0].characters.length).toEqual 2
    ctrl.apikeys[0].characters = []
    ctrl.refreshKey(ctrl.apikeys[0])
    scope.$apply()
    expect(ctrl.apikeys[0].characters.length).toEqual 2

  it 'should handle API key refresh failure', () ->
    scope.$apply()
    throwError = true
    ctrl.refreshKey(ctrl.apikeys[0])
    scope.$apply()
    expect(ctrl.alerts.length).toEqual 1
    ctrl.closeAlert(0)
    expect(ctrl.alerts.length).toEqual 0
