test/unit/hqmf_javascript_test.rb in hqmf2js-1.3.0 vs test/unit/hqmf_javascript_test.rb in hqmf2js-1.4.0

- old
+ new

@@ -1,15 +1,14 @@ require_relative '../test_helper' require 'hquery-patient-api' -class HqmfJavascriptTest < Test::Unit::TestCase +class HqmfJavascriptTest < Minitest::Test def setup # Open a path to all of our fixtures - hqmf_contents = File.open("test/fixtures/NQF59New.xml").read - - doc = HQMF::Parser.parse(hqmf_contents, HQMF::Parser::HQMF_VERSION_2) - + model = JSON.parse(File.open("test/fixtures/NQF59New.json").read) + doc = HQMF::Document.from_json(model) + codes_file_path = File.expand_path("../../fixtures/codes/codes.xml", __FILE__) # First compile the CoffeeScript that enables our converted HQMF JavaScript hqmf_utils = compile_coffee_script @@ -47,15 +46,15 @@ local_context = V8::Context.new hqmf_utils = HQMF2JS::Generator::JS.library_functions local_context.eval("#{hqmf_utils} #{value}") - local_context.eval('typeof hqmfjs != undefined').must_equal true - local_context.eval('typeof OidDictionary != undefined').must_equal true - local_context.eval('typeof hqmfjs.IPP != undefined').must_equal true - local_context.eval('typeof hqmfjs.NUMER != undefined').must_equal true - local_context.eval('typeof hqmfjs.DENOM != undefined').must_equal true + assert_equal true, local_context.eval('typeof hqmfjs != undefined') + assert_equal true, local_context.eval('typeof OidDictionary != undefined') + assert_equal true, local_context.eval('typeof hqmfjs.IPP != undefined') + assert_equal true, local_context.eval('typeof hqmfjs.NUMER != undefined') + assert_equal true, local_context.eval('typeof hqmfjs.DENOM != undefined') end def test_to_js_method_without_codes value = @converter.to_js(0,nil) assert !value.match(/<%= oid_dictionary %>/).nil? @@ -183,12 +182,12 @@ assert_equal 11, @context.eval('normalizedEncounters[0].endDate().getUTCMonth()') assert_equal 1, @context.eval('normalizedEncounters[0].endDate().getUTCDate()') end def test_map_reduce_generation - hqmf_contents = File.open("test/fixtures/NQF59New.xml").read - doc = HQMF::Parser.parse(hqmf_contents, HQMF::Parser::HQMF_VERSION_2) + model = JSON.parse(File.open("test/fixtures/NQF59New.json").read) + doc = HQMF::Document.from_json(model) map_reduce = HQMF2JS::Converter.generate_map_reduce(doc) # Extremely loose testing here. Just want to be sure for now that we're getting results of some kind. # We'll test for validity over on the hQuery Gateway side of things. @@ -204,10 +203,10 @@ def test_missing_id context = HQMF2JS::Generator::ErbContext.new({}) criteria = HQMF::DataCriteria.new(nil,nil,nil,nil,nil,nil,nil,'patient_characteristic',nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil) - exception = assert_raise RuntimeError do + exception = assert_raises RuntimeError do n = context.js_name(criteria) end assert exception.message.match(/^No identifier for .*/) end \ No newline at end of file