<commit_before>'use strict';

require('mocha');
const fs = require('fs');
const assert = require('assert');
const { timeout, keypresses } = require('./support')(assert);
const AutoComplete = require('../lib/prompts/autocomplete');
let prompt;

const fixtures = ['almond', 'apple', 'banana', 'cherry', 'chocolate', 'cinnamon', 'coconut', 'cotton candy', 'grape', 'nougat', 'orange', 'pear', 'pineapple', 'strawberry', 'vanilla', 'watermelon', 'wintergreen'];

class Prompt extends AutoComplete {
  constructor(options) {
    super({ ...options, show: false });
  }
}

describe('prompt-autocomplete', () => {
  describe('keypress > number', () => {
    it('should support number keypresses', () => {
      prompt = new Prompt({
        message: 'Favorite flavor?',
        choices: [
          { message: 'a', value: 'A' },
          { message: 'b', value: 'BB' },
          { message: 'c', value: 'CCC' },
          { message: 'd', value: 'DDDD' }
        ]
      });

      prompt.once('run', async() => {
        await prompt.keypress(1);
        await prompt.keypress(3);
        await prompt.keypress(2);
        await prompt.submit();
      });

      return prompt.run().then(answer => {
        assert.equal(answer, 'CCC');
      });
    });

    it('should filter by keypress', function() {
      this.timeout(5000);

      prompt = new Prompt({
        message: 'Favorite letters?',
        choices: [
          { message: 'aab', value: 'A' },<commit_msg>test: fix autocomplete number test<commit_after>'use strict';

require('mocha');
const fs = require('fs');
const assert = require('assert');
const { timeout, keypresses } = require('./support')(assert);
const AutoComplete = require('../lib/prompts/autocomplete');
let prompt;

const fixtures = ['almond', 'apple', 'banana', 'cherry', 'chocolate', 'cinnamon', 'coconut', 'cotton candy', 'grape', 'nougat', 'orange', 'pear', 'pineapple', 'strawberry', 'vanilla', 'watermelon', 'wintergreen'];

class Prompt extends AutoComplete {
  constructor(options) {
    super({ ...options, show: false });
  }
}

describe('prompt-autocomplete', () => {
  describe('keypress > number', () => {
    it('should support number keypresses', () => {
      prompt = new Prompt({
        message: 'Favorite flavor?',
        choices: [
          { message: '2a', value: 'A' },
          { message: '321b', value: 'BB' },
          { message: '123c', value: 'CCC' },
          { message: '1d', value: 'DDDD' }
        ]
      });

      prompt.once('run', async() => {
        await prompt.keypress(1);
        await prompt.keypress(2);
        await prompt.keypress(3);
        await prompt.submit();
      });

      return prompt.run().then(answer => {
        assert.equal(answer, 'CCC');
      });
    });

    it('should filter by keypress', function() {
      this.timeout(5000);

      prompt = new Prompt({
        message: 'Favorite letters?',
        choices: [
          { message: 'aab', value: 'A' },
{'fraction_non_alphanumeric': 0.19052453468697123, 'fraction_numerical': 0.007445008460236886, 'mean_word_length': 2.853976531942634, 'pattern_counts': {'":': 0, '<': 3, '<?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': '331757', 'n_tokens_mistral': 944, 'n_tokens_neox': 910, 'n_words': 220}