<commit_before>describe 'WebSocketRails.Channel:', ->
  beforeEach ->
    @dispatcher =
      new_message: -> true
      dispatch: -> true
      trigger_event: (event) -> true
      state: 'connected'
      connection_id: 12345
    @channel = new WebSocketRails.Channel('public',@dispatcher)
    sinon.spy @dispatcher, 'trigger_event'

  afterEach ->
    @dispatcher.trigger_event.restore()

  describe '.trigger', ->
    describe 'before the channel token is set', ->
      it 'queues the events', ->
        @channel.trigger 'someEvent', 'someData'
        queue = @channel._queue
        expect(queue[0].name).toEqual 'someEvent'
        expect(queue[0].data).toEqual 'someData'<commit_msg>channel spec: verify the token is set before dispatching event<commit_after>describe 'WebSocketRails.Channel:', ->
  beforeEach ->
    @dispatcher =
      new_message: -> true
      dispatch: -> true
      trigger_event: (event) -> true
      state: 'connected'
      connection_id: 12345
    @channel = new WebSocketRails.Channel('public',@dispatcher)
    sinon.spy @dispatcher, 'trigger_event'

  afterEach ->
    @dispatcher.trigger_event.restore()

  describe '.trigger', ->
    describe 'before the channel token is set', ->
      it 'queues the events', ->
        @channel.trigger 'someEvent', 'someData'
        queue = @channel._queue
        expect(queue[0].name).toEqual 'someEvent'
        expect(queue[0].data).toEqual 'someData'

    describe 'when channel token is set', ->
      it 'adds token to event metadata and dispatches event', ->
        @channel._token = 'valid token'
        @channel.trigger 'someEvent', 'someData'
        expect(@dispatcher.trigger_event.calledWith(['someEvent',{token: 'valid token', data: 'someData'}]))
{'fraction_non_alphanumeric': 0.13073394495412843, 'fraction_numerical': 0.008027522935779817, 'mean_word_length': 3.096244131455399, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '7315782', 'n_tokens_mistral': 518, 'n_tokens_neox': 505, 'n_words': 124}