<commit_before>import test from 'ava'
import { createRest } from '../lib'
import { printRoutes } from '../lib/printer'

/* eslint-disable no-shadow */

const get = () => {}
const post = () => {}
const put = () => {}
const patch = () => {}
const destroy = () => {}
const before = () => {}
const after = () => {}

const make = (method, listeners = []) => ({
  method, listeners,
})

test('Simple with before/after', t => {
  t.deepEqual(
    printRoutes(createRest(r => {
      r.before(before)
      r.after(after)
      r.get(get)
      r.post('foo', post)
    }), false),
    [
      'GET / -> before(), get(), after()',
      'POST /foo/ -> before(), post(), after()',
    ]
  )
})

test('Scoped with before/after', t => {
  t.deepEqual(
    printRoutes(createRest(r => {
      r.before(before)
      r.after(after)
      r.get(get)
      r.post('foo', post)
      r.scope('bar', r => {
        r.before(before)
        r.after(after)
        r.put(() => {})
        r.delete('baz', destroy)
      })
    }), false),
    [
      'GET / -> before(), get(), after()',
      'POST /foo/ -> before(), post(), after()',
      'PUT /bar/ -> before(), before(), <function>(), after(), after()',
      'DELETE /bar/baz/ -> before(), before(), destroy(), after(), after()'
    ]
  )
})

test.todo('Real print to stdout')

test('Real print to output', t => {
  printRoutes(createRest(r => {
    r.before(before)
    r.after(after)
    r.get(get)
    r.post('foo', post)
  }), false)
  t.pass()
})
<commit_msg>Full coverage<commit_after>import test from 'ava'
import { createRest } from '../lib'
import { printRoutes } from '../lib/printer'

/* eslint-disable no-shadow */

const get = () => {}
const post = () => {}
const put = () => {}
const patch = () => {}
const destroy = () => {}
const before = () => {}
const after = () => {}

const make = (method, listeners = []) => ({
  method, listeners,
})

test('Simple with before/after', t => {
  t.deepEqual(
    printRoutes(createRest(r => {
      r.before(before)
      r.after(after)
      r.get(get)
      r.post('foo', post)
    }), false),
    [
      'GET / -> before(), get(), after()',
      'POST /foo/ -> before(), post(), after()',
    ]
  )
})

test('Scoped with before/after', t => {
  t.deepEqual(
    printRoutes(createRest(r => {
      r.before(before)
      r.after(after)
      r.get(get)
      r.post('foo', post)
      r.scope('bar', r => {
        r.before(before)
        r.after(after)
        r.put(() => {})
        r.delete('baz', destroy)
      })
    }), false),
    [
      'GET / -> before(), get(), after()',
      'POST /foo/ -> before(), post(), after()',
      'PUT /bar/ -> before(), before(), <function>(), after(), after()',
      'DELETE /bar/baz/ -> before(), before(), destroy(), after(), after()'
    ]
  )
})

test.todo('Real print to stdout')

test('Real print to output', t => {
  printRoutes(createRest(r => {
    r.before(before)
    r.after(after)
    r.get(get)
    r.post('foo', post)
  }))
  t.pass()
})

{'fraction_non_alphanumeric': 0.22938230383973288, 'fraction_numerical': 0.0, 'mean_word_length': 2.392978482446206, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '1030934', 'n_tokens_mistral': 1039, 'n_tokens_neox': 1035, 'n_words': 228}