import PlayerError from '../../src/components/error'
import Core from '../../src/components/core'
import Events from '../../src/base/events'

describe('PlayerError', function() {
  beforeEach(function() {
    this.core = new Core({})

    this.errorData = {
      code: 'test_01',
      description: 'test error',
      level: PlayerError.Levels.FATAL,
      origin: 'test',
      scope: 'it',
      raw: {},
    }
  })

  describe('when error method is called', function() {
    it('trigger ERROR event', function() {
      sinon.spy(this.core, 'trigger')
      PlayerError.error(this.errorData)

      assert.ok(this.core.trigger.calledWith(Events.ERROR, {
        code: 'test_01',
        description: 'test error',
        level: PlayerError.Levels.FATAL,
        origin: 'test',
        scope: 'it',
        raw: {},
      }))
    })

    describe('when core is not setted', function() {
      it('does not trigger ERROR event', function() {
        sinon.spy(this.core, 'trigger')
        PlayerError.core = undefined
        PlayerError.error(this.errorData)

        assert.notOk(this.core.trigger.calledWith(Events.ERROR, this.errorData))
      })
    })
  })
})

@@ -1,57 +1,4 @@
-import PlayerError from '../../src/components/error'%0A
 impo
@@ -38,16 +38,16 @@
 s/core'%0A
+
 import E
@@ -174,17 +174,61 @@
 ore(%7B%7D)%0A
+    this.playerError = this.core.playerError
 %0A
-
     this
@@ -303,33 +303,38 @@
 ',%0A      level: 
-P
+this.p
 layerError.Level
@@ -548,25 +548,30 @@
 ger')%0A      
-P
+this.p
 layerError.e
@@ -728,17 +728,22 @@
  level: 
-P
+this.p
 layerErr
@@ -986,33 +986,38 @@
 igger')%0A        
-P
+this.p
 layerError.core 
@@ -1036,17 +1036,22 @@
         
-P
+this.p
 layerErr

use playerError instance from core fixes test