<commit_before>import Quick
import Nimble
import Clappr

class PlayerTests: QuickSpec {
    override func spec() {
        describe("Player") {
            
            let options = [kSourceUrl : "http://someUrl.com"]
            
            it("Should load source on core when initializing") {
                let player = Player(options: options as Options)
                
                if let core = player.core {
                    expect(core.activeContainer).toNot(beNil())
                } else {
                    fail("player.core is nil")
                }
            }
            
            
            
            
        
            
        }
    }
}
<commit_msg>feat(event): create tests to handle player events<commit_after>import Quick
import Nimble
import Clappr

class PlayerTests: QuickSpec {
    static let specialSource = "specialSource"
    
    override func spec() {
        describe("Player") {
                       
            let options = [kSourceUrl : "http://clappr.com/video.mp4"]
           
            var player: Player!
            var playback: StubPlayback!
            
            beforeEach() {
                player = Player(options: options, externalPlugins: [SpecialStubPlayback.self, StubPlayback.self])
                playback = player.activePlayback as! StubPlayback
            }
            
            it("Should load source on core when initializing") {
                let player = Player(options: options as Options)
                
                if let core = player.core {
                    expect(core.activeContainer).toNot(beNil())
                } else {
                    fail("player.core is nil")
                }
            }
            
            it("Should listen to playing event") {
                var callbacklWasCalled = false
                
                player.on(.playing) { _ in
                    callbacklWasCalled = true
                }
                
                playback.trigger(.playing)
                expect(callbacklWasCalled).to(beTrue())
            }
            
            it("Should route events after new playback is created") {
                var callbacklWasCalled = false
                
                player.on(.playing) { _ in
                    callbacklWasCalled = true
                }
                
                expect(player.activePlayback is StubPlayback).to(beTrue())
                player.load(PlayerTests.specialSource)
                expect(player.activePlayback is SpecialStubPlayback).to(beTrue())
                
                player.activePlayback?.trigger(.playing)
                expect(callbacklWasCalled).to(beTrue())
            }
        }
    }
   
    class StubPlayback: Playback {
        override var pluginName: String {
            return "StubPlayback"
        }
        
        override class func canPlay(_ options: Options) -> Bool {
            return true
        }
    }
    
    class SpecialStubPlayback: Playback {
        override var pluginName: String {
            return "SpecialStubPlayback"
        }
        
        override class func canPlay(_ options: Options) -> Bool {
            return options[kSourceUrl] as! String == PlayerTests.specialSource
        }
    }
}

{'fraction_non_alphanumeric': 0.07551766138855055, 'fraction_numerical': 0.0003045066991473812, 'mean_word_length': 1.242320819112628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4501978', 'n_tokens_mistral': 799, 'n_tokens_neox': 765, 'n_words': 182}