#!/usr/bin/env ruby
#
require 'minitest/unit'
require 'minitest/autorun'
require 'grape'
require_relative '../lib/classes.rb'

class AskMeTestClass < MiniTest::Unit::TestCase

  include Helpers

  def test_filter_fields
    input = { fielda: "valuea", fieldb: "valueb", fieldc: "valuec" }

    assert_equal(filter_fields(input), input)
    assert_equal(filter_fields(input, false), input)
    assert_equal(filter_fields(input, ["array"]), input)
    assert_equal(filter_fields(input, { "key" => "value" }), input)
    assert_equal(filter_fields(input, "fielda"), { "fielda" => "valuea" })
    assert_equal(filter_fields(input, "fielda"), { "fielda" => "valuea" })
    assert_equal(filter_fields(input, "fielda,fieldb"),
      { "fielda" => "valuea", "fieldb" => "valueb" })
    assert_equal(filter_fields(input, "fieldb,fielda"),
      { "fielda" => "valuea", "fieldb" => "valueb" })
  end

end
