Skip to content

Commit

Permalink
Fixed tests for VA code parser so far, look for type-specific fields …
Browse files Browse the repository at this point in the history
…in the type-specific subobject
  • Loading branch information
konklone committed Nov 4, 2012
1 parent f8cecd0 commit 3ad1ceb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions test/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<script type="text/javascript" src="../citation.js"></script>
<script type="text/javascript" src="../citations/usc.js"></script>
<script type="text/javascript" src="../citations/law.js"></script>
<script type="text/javascript" src="../citations/us_va.js"></script>

</head>
<body>
Expand Down
17 changes: 9 additions & 8 deletions test/us_va.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
Tests for extracting slip law citations from legislation.
Each test should link to a real world circumstance where possible.
Tests for extracting Virginia Code citations.
*/

var Citation = require('../citation');


exports.testPatterns = function(test) {
test.expect();

var cases = [
// variations on text of http://www.gpo.gov/fdsys/pkg/BILLS-112hr2367ih/xml/BILLS-112hr2367ih.xml
['Va. Code Ann. § 19.2-56.2 (2010)', '19.2', '56.2', '2010'],
['Va. Code Ann. § 19.2-56.2 (West 2010)', '19.2', '56.2', '2010']
];
Expand All @@ -18,15 +18,16 @@ exports.testPatterns = function(test) {

var text = details[0];
var found = Citation.find(text);
test.equal(found.length, 1, "No match found in: " + text);
test.equal(found.length, 1);

if (found.length == 1) {
var citation = found[0];
test.equal(citation.match, details[0]);
test.equal(citation.title, details[1]);
test.equal(citation.section, details[2]);
test.equal(citation.year, details[3]);
}
test.equal(citation.va_code_ann.title, details[1]);
test.equal(citation.va_code_ann.section, details[2]);
test.equal(citation.va_code_ann.year, details[3]);
} else
console.log("No match found in: " + text);
}

test.done();
Expand Down

0 comments on commit 3ad1ceb

Please sign in to comment.