<commit_before>
mecano = require '../../src'
test = require '../test'
fs = require 'fs'
domain = require 'domain'

describe 'api call', ->

  scratch = test.scratch @

  describe 'sync', ->

    it 'execute a handler', (next) ->
      called = 0
      touched = 0
      mecano
      .touch
        destination: "#{scratch}/file_a"
      , (err) ->
        touched++
      .call (options) ->
        called++
      .touch
        destination: "#{scratch}/file_b"
      , (err) ->
        touched++
      .then (err, status) ->
        called.should.eql 1 unless err
        touched.should.eql 2 unless err
        next err

    it.skip 'execute a callback', (next) ->
      called = 0
      touched = 0
      mecano
      .touch
        destination: "#{scratch}/a_file"
      , (err) ->
        touched++
      .call ((options) ->), (err, status) ->
        called++ unless err
      .touch
        destination: "#{scratch}/a_file"
      , (err) ->
        touched++
      .then (err, status) ->
        called.should.eql 1
        touched.should.eql 2
        next()

    it 'pass options', (next) ->
      mecano
      .call test: true, (options) ->
        options.test.should.be.true()
      .then next

    it 'pass multiple options', (next) ->
      mecano
      .call {test1: true}, {test2: true}, (options) ->
        options.test1.should.be.true()
        options.test2.should.be.true()
      .then next

  describe 'async', ->

    it 'execute a handler', (next) ->
      called = 0
      touched = 0
      mecano
      .touch
        destination: "#{scratch}/a_file"
      , (err) ->
        touched++
      .call (options, next) -><commit_msg>call: rehabilitate callback sync test<commit_after>
mecano = require '../../src'
test = require '../test'
fs = require 'fs'
domain = require 'domain'

describe 'api call', ->

  scratch = test.scratch @

  describe 'sync', ->

    it 'execute a handler', (next) ->
      called = 0
      touched = 0
      mecano
      .touch
        destination: "#{scratch}/file_a"
      , (err) ->
        touched++
      .call (options) ->
        called++
      .touch
        destination: "#{scratch}/file_b"
      , (err) ->
        touched++
      .then (err, status) ->
        called.should.eql 1 unless err
        touched.should.eql 2 unless err
        next err

    it 'execute a callback', (next) ->
      called = 0
      mecano
      .call ((options) ->), (err, status) ->
        called++ unless err
      .then (err, status) ->
        called.should.eql 1
        next()

    it 'pass options', (next) ->
      mecano
      .call test: true, (options) ->
        options.test.should.be.true()
      .then next

    it 'pass multiple options', (next) ->
      mecano
      .call {test1: true}, {test2: true}, (options) ->
        options.test1.should.be.true()
        options.test2.should.be.true()
      .then next

  describe 'async', ->

    it 'execute a handler', (next) ->
      called = 0
      touched = 0
      mecano
      .touch
        destination: "#{scratch}/a_file"
      , (err) ->
        touched++
      .call (options, next) ->
{'fraction_non_alphanumeric': 0.14990328820116053, 'fraction_numerical': 0.008381689232753063, 'mean_word_length': 1.658954584404456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, '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': '1737811', 'n_tokens_mistral': 1004, 'n_tokens_neox': 987, 'n_words': 268}