<commit_before>const {
  bus,
  routine,
  request
 } = require('./snurra')

it('can create a bus', () => {
  const app = bus()
})

it('handlers can issue requests', () => {
  const app = bus()
  app.install(
    routine('hello').started(val => {
      return request('capitalize', val)
    }),
    routine('capitalize')
      .started(val => val.toUpperCase())
  )
  return app.request('hello', 'world').then(result =>
    expect(result).toBe('WORLD')
  )
})

it('handler of impure routine can return a promise', () => {
  const app = bus()
  app.install(
    routine('hello').started(val => {
      return request('async-capitalize', val)
    }),
    routine.impure('async-capitalize')
      .started(val => Promise.resolve(val.toUpperCase()))
  )
  return app.request('hello', 'world').then(result =>
    expect(result).toBe('WORLD')
  )
})

it('handler of pure routine cannot return a promise', () => {
  const app = bus()
  app.install(
    routine('hello').started(() => {
      return new Promise(() => {})
    })
  )
  return expect(
    app.request('hello')
  ).rejects.toThrow('Handler of impure routine is not allowed to return promises')
})

it('can do things', () => {
  const app = bus()
  app.install(
    routine('hello').started(() =>
      'world')
  )
  return app.request('hello').then(
    result => expect(result).toBe('world')
  )
})<commit_msg>delete redundant test<commit_after>const {
  bus,
  routine,
  request
 } = require('./snurra')

it('handlers can issue requests', () => {
  const app = bus()
  app.install(
    routine('hello').started(val => {
      return request('capitalize', val)
    }),
    routine('capitalize')
      .started(val => val.toUpperCase())
  )
  return app.request('hello', 'world').then(result =>
    expect(result).toBe('WORLD')
  )
})

it('handler of impure routine can return a promise', () => {
  const app = bus()
  app.install(
    routine('hello').started(val => {
      return request('async-capitalize', val)
    }),
    routine.impure('async-capitalize')
      .started(val => Promise.resolve(val.toUpperCase()))
  )
  return app.request('hello', 'world').then(result =>
    expect(result).toBe('WORLD')
  )
})

it('handler of pure routine cannot return a promise', () => {
  const app = bus()
  app.install(
    routine('hello').started(() => {
      return new Promise(() => {})
    })
  )
  return expect(
    app.request('hello')
  ).rejects.toThrow('Handler of impure routine is not allowed to return promises')
})

it('can do things', () => {
  const app = bus()
  app.install(
    routine('hello').started(() =>
      'world')
  )
  return app.request('hello').then(
    result => expect(result).toBe('world')
  )
})
{'fraction_non_alphanumeric': 0.1911491260691707, 'fraction_numerical': 0.0, 'mean_word_length': 3.297124600638978, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 32, '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': '6133606', 'n_tokens_mistral': 876, 'n_tokens_neox': 865, 'n_words': 189}