<commit_before>sinos = require('../index')

describe 'sinos-river-level-twitter', ->
  describe '#search', ->
    it 'is a function', ->
      expect(sinos.search).to.be.instanceof Function<commit_msg>Test for calls on index<commit_after>Stream  = require('stream')
Twitter = require('twitter')
sinos   = require('../index')
config  = require('../lib/config')

describe 'sinos-river-level-twitter', ->
  describe '#search', ->
    beforeEach ->
      @stub = sinon.stub Twitter::, 'get'

    afterEach ->
      @stub.restore()

    it 'is a function', ->
      expect(sinos.search).to.be.instanceof Function

    it 'calls twitter search', ->
      sinos.search {query: 'foo-bar'}, ->
      sinon.assert.calledWith(@stub, 'search/tweets', {q: 'foo-bar'})

    it 'pass a stream to callback', (done) ->
      sinos.search {query: 'foo-bar'}, (stream) ->
        expect(stream).to.be.instanceof Stream
        done()

    it 'updates config key from options', ->
      query = 'foo-bar'; key = 'abcd'; secret = '1234'
      sinos.search {query, key, secret}, ->
      expect(config).to.have.property 'TWITTER_CONSUMER_KEY', 'abcd'

    it 'updates config secret from options', ->
      query = 'foo-bar'; key = 'abcd'; secret = '1234'
      sinos.search {query, key, secret}, ->
      expect(config).to.have.property 'TWITTER_CONSUMER_SECRET', '1234'
{'fraction_non_alphanumeric': 0.17359050445103857, 'fraction_numerical': 0.008902077151335312, 'mean_word_length': 3.0148809523809526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '624405', 'n_tokens_mistral': 457, 'n_tokens_neox': 438, 'n_words': 103}