<commit_before>
nikita = require '../../src'
{tags, ssh} = require '../test'
they = require('ssh2-they').configure ssh

return unless tags.posix

describe 'actions.wait', ->

  they 'time as main argument', ({ssh}) ->
    before = 0
    nikita
      ssh: ssh
    .call ->
      before = Date.now()
    .wait 500
    .wait '500'
    .wait 0
    .call ->
      interval = Date.now() - before
      (interval >= 1000 and interval < 1500).should.be.true()

  they 'validate argument', ({ssh}) ->
    before = Date.now()
    nikita
      ssh: ssh
    .wait
      time: 'an': 'object'
    .should.be.rejectedWith [
      'NIKITA_SCHEMA_VALIDATION_CONFIG:'
      'one error was found in the configuration of action `wait`:'
      '#/properties/time/type config.time should be integer,'
      'type is "integer".'
    ].join ' '<commit_msg>test(engine): rewrite wait test and reduce time<commit_after>
nikita = require '../../src'
{tags, ssh} = require '../test'
they = require('ssh2-they').configure ssh

return unless tags.posix

describe 'actions.wait', ->

  they 'time as main argument', ({ssh}) ->
    nikita
      ssh: ssh
    , ->
      {before} = await @call ->
        before: Date.now()
      await @wait 200
      await @wait '200'
      await @wait 0
      interval = Date.now() - before
      (interval >= 400 and interval < 600).should.be.true()

  they 'validate argument', ({ssh}) ->
    before = Date.now()
    nikita
      ssh: ssh
    .wait
      time: 'an': 'object'
    .should.be.rejectedWith [
      'NIKITA_SCHEMA_VALIDATION_CONFIG:'
      'one error was found in the configuration of action `wait`:'
      '#/properties/time/type config.time should be integer,'
      'type is "integer".'
    ].join ' '
{'fraction_non_alphanumeric': 0.1493317838466008, 'fraction_numerical': 0.01801278326554329, 'mean_word_length': 2.350194552529183, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '3003639', 'n_tokens_mistral': 591, 'n_tokens_neox': 539, 'n_words': 166}