Class: MarkdownExec::TestMarkdownTableFormatter

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/markdown_exec.rb

Instance Method Summary collapse

Instance Method Details

#test_select_document_if_multipleObject



1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
# File 'lib/markdown_exec.rb', line 1105

def test_select_document_if_multiple
  find_path = "#{`pwd`.chomp}/fixtures"
  value = 'fix'
  searcher = SearchResultsReport.new(value, [find_path])
  options = {
    ansi_formatter_color: false,
    block_name_match: ':(?<title>\\S+)( |$)',
    block_name_nick_match: '^\[.*\]$',
    fenced_start_and_end_regex: '^(?<indent>[ \t]*)`{3,}',
    menu_active_color_pastel_messages: %w[inverse]
  }

  file_names = searcher.file_names(options, value)
  assert_equal ({ section_title: 'file names', data: [], formatted_text: [{ content: '' }] }),
               file_names

  found_in_block_names = searcher.found_in_block_names(options, value,
                                                       formspec: '%<line>s')
  assert_equal ({ section_title: 'block names',
                  data: [],
                  formatted_text: [],
                  matched_contents: [] }), found_in_block_names

  directory_names = searcher.directory_names(options, value)
  assert_equal ({ section_title: 'directory names',
                  data: ["#{Dir.getwd}/fixtures"],
                  formatted_text: [{ content: ["#{Dir.getwd}/fixtures"] }] }), directory_names

  mp = MarkdownExec::MarkParse.new(options)

  file_name_choices = mp.choices_from_file_names(
    directory_names, colorize: false, histogram: false, pattern: 'y*'
  )
  assert_equal ['fixtures/yaml1.md',
                'fixtures/yaml2.md'], file_name_choices

  choices = MenuBuilder.new.build_menu(
    file_names, directory_names, found_in_block_names,
    file_name_choices, mp.choices_from_block_names(value, found_in_block_names),
    colorize: false
  )
  assert_equal [{ disabled: '', name: 'in file names' },
                { disabled: '', name: 'in directory names' },
                'fixtures/yaml1.md',
                'fixtures/yaml2.md',
                { disabled: '', name: 'in block names' }], choices

  # @options[:filename] = FileInMenu.from_menu(
  #   mp.select_document_if_multiple(
  #     choices,
  #     # test_select: 0,
  #     prompt: options[:prompt_select_md].to_s +
  #      AnsiString.new(' ¤ Age in months').fg_rgbh_AF_AF_00
  #   )
  # )
end