Sha256: 4607bcf0e18d26309e5cb9a8edb826af0284fad5d563671f8183d501cac98471

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require_relative 'test_helper'

module BNF
  class TreeTest < Minitest::Test

    def test_yield_to_a_block_for_each
      block_called = false
      @tree.each do |h|
        block_called = true
        break
      end
      assert block_called
    end

    def test_find_by_name_capitalised
      heading = @tree.find('Paracetamol')
      refute_nil heading
      assert_equal 'https://www.evidence.nhs.uk/formulary/bnf/current/4-central-nervous-system/47-analgesics/471-non-opioid-analgesics-and-compound-analgesic-preparations/paracetamol', heading.uri
      assert_equal 'PARACETAMOL', heading.title
    end

    def test_find_by_name_lowercase
      heading = @tree.find('dalteparin sodium')
      refute_nil heading
      assert_equal 'DALTEPARIN SODIUM', heading.title
    end


    def test_find_by_name_uppercase
      heading = @tree.find('DALTEPARIN SODIUM')
      refute_nil heading
      assert_equal 'DALTEPARIN SODIUM', heading.title
    end


    def test_find_by_name_ignore_whitespace
      heading = @tree.find('   DALTEPARIN   SODIUM  ')
      refute_nil heading
      assert_equal 'DALTEPARIN SODIUM', heading.title
    end

    def test_find_by_regex
      heading = @tree.find(/^DALTEPARIN/)
      refute_nil heading
      assert_equal 'DALTEPARIN SODIUM', heading.title
    end



    def setup
      @@tree ||= BNF::Tree.new(:bnf)
      @tree = @@tree
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
BNF-0.0.1 test/tree_test.rb