diff --git a/test/data/collection.json b/test/data/collection.json new file mode 100644 index 0000000..0ff4791 --- /dev/null +++ b/test/data/collection.json @@ -0,0 +1,522 @@ +[ + { + "leader":"00925njm 22002777a 4500", + "fields":[ + { + "001":"5637241" + }, + { + "003":"DLC" + }, + { + "005":"19920826084036.0" + }, + { + "007":"sdubumennmplu" + }, + { + "008":"910926s1957 nyuuun eng " + }, + { + "010":{ + "subfields":[ + { + "a":" 91758335 " + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "028":{ + "subfields":[ + { + "a":"1259" + }, + { + "b":"Atlantic" + } + ], + "ind1":"0", + "ind2":"0" + } + }, + { + "040":{ + "subfields":[ + { + "a":"DLC" + }, + { + "c":"DLC" + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "050":{ + "subfields":[ + { + "a":"Atlantic 1259" + } + ], + "ind1":"0", + "ind2":"0" + } + }, + { + "245":{ + "subfields":[ + { + "a":"The Great Ray Charles" + }, + { + "h":"[sound recording]." + } + ], + "ind1":"0", + "ind2":"4" + } + }, + { + "260":{ + "subfields":[ + { + "a":"New York, N.Y. :" + }, + { + "b":"Atlantic," + }, + { + "c":"[1957?]" + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "300":{ + "subfields":[ + { + "a":"1 sound disc :" + }, + { + "b":"analog, 33 1/3 rpm ;" + }, + { + "c":"12 in." + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "511":{ + "subfields":[ + { + "a":"Ray Charles, piano & celeste." + } + ], + "ind1":"0", + "ind2":" " + } + }, + { + "505":{ + "subfields":[ + { + "a":"The Ray -- My melancholy baby -- Black coffee -- There's no you -- Doodlin' -- Sweet sixteen bars -- I surrender dear -- Undecided." + } + ], + "ind1":"0", + "ind2":" " + } + }, + { + "500":{ + "subfields":[ + { + "a":"Brief record." + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "650":{ + "subfields":[ + { + "a":"Jazz" + }, + { + "y":"1951-1960." + } + ], + "ind1":" ", + "ind2":"0" + } + }, + { + "650":{ + "subfields":[ + { + "a":"Piano with jazz ensemble." + } + ], + "ind1":" ", + "ind2":"0" + } + }, + { + "700":{ + "subfields":[ + { + "a":"Charles, Ray," + }, + { + "d":"1930-" + }, + { + "4":"prf" + } + ], + "ind1":"1", + "ind2":" " + } + } + ] + }, + { + "leader":"01832cmma 2200349 a 4500", + "fields":[ + { + "001":"12149120" + }, + { + "005":"20001005175443.0" + }, + { + "007":"cr |||" + }, + { + "008":"000407m19949999dcu g m eng d" + }, + { + "906":{ + "subfields":[ + { + "a":"0" + }, + { + "b":"ibc" + }, + { + "c":"copycat" + }, + { + "d":"1" + }, + { + "e":"ncip" + }, + { + "f":"20" + }, + { + "g":"y-gencompf" + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "925":{ + "subfields":[ + { + "a":"undetermined" + }, + { + "x":"web preservation project (wpp)" + } + ], + "ind1":"0", + "ind2":" " + } + }, + { + "955":{ + "subfields":[ + { + "a":"vb07 (stars done) 08-19-00 to HLCD lk00; AA3s lk29 received for subject Aug 25, 2000; to DEWEY 08-25-00; aa11 08-28-00" + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "010":{ + "subfields":[ + { + "a":" 00530046 " + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "035":{ + "subfields":[ + { + "a":"(OCoLC)ocm44279786" + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "040":{ + "subfields":[ + { + "a":"IEU" + }, + { + "c":"IEU" + }, + { + "d":"N@F" + }, + { + "d":"DLC" + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "042":{ + "subfields":[ + { + "a":"lccopycat" + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "043":{ + "subfields":[ + { + "a":"n-us-dc" + }, + { + "a":"n-us---" + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "050":{ + "subfields":[ + { + "a":"F204.W5" + } + ], + "ind1":"0", + "ind2":"0" + } + }, + { + "082":{ + "subfields":[ + { + "a":"975.3" + }, + { + "2":"13" + } + ], + "ind1":"1", + "ind2":"0" + } + }, + { + "245":{ + "subfields":[ + { + "a":"The White House" + }, + { + "h":"[computer file]." + } + ], + "ind1":"0", + "ind2":"4" + } + }, + { + "256":{ + "subfields":[ + { + "a":"Computer data." + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "260":{ + "subfields":[ + { + "a":"Washington, D.C. :" + }, + { + "b":"White House Web Team," + }, + { + "c":"1994-" + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "538":{ + "subfields":[ + { + "a":"Mode of access: Internet." + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "500":{ + "subfields":[ + { + "a":"Title from home page as viewed on Aug. 19, 2000." + } + ], + "ind1":" ", + "ind2":" " + } + }, + { + "520":{ + "subfields":[ + { + "a":"Features the White House. Highlights the Executive Office of the President, which includes senior policy advisors and offices responsible for the President's correspondence and communications, the Office of the Vice President, and the Office of the First Lady. Posts contact information via mailing address, telephone and fax numbers, and e-mail. Contains the Interactive Citizens' Handbook with information on health, travel and tourism, education and training, and housing. Provides a tour and the history of the White House. Links to White House for Kids." + } + ], + "ind1":"8", + "ind2":" " + } + }, + { + "610":{ + "subfields":[ + { + "a":"White House (Washington, D.C.)" + } + ], + "ind1":"2", + "ind2":"0" + } + }, + { + "610":{ + "subfields":[ + { + "a":"United States." + }, + { + "b":"Executive Office of the President." + } + ], + "ind1":"1", + "ind2":"0" + } + }, + { + "610":{ + "subfields":[ + { + "a":"United States." + }, + { + "b":"Office of the Vice President." + } + ], + "ind1":"1", + "ind2":"0" + } + }, + { + "610":{ + "subfields":[ + { + "a":"United States." + }, + { + "b":"Office of the First Lady." + } + ], + "ind1":"1", + "ind2":"0" + } + }, + { + "710":{ + "subfields":[ + { + "a":"White House Web Team." + } + ], + "ind1":"2", + "ind2":" " + } + }, + { + "856":{ + "subfields":[ + { + "u":"http://www.whitehouse.gov" + } + ], + "ind1":"4", + "ind2":"0" + } + }, + { + "856":{ + "subfields":[ + { + "u":"http://lcweb.loc.gov/staff/wpp/whitehouse.html" + }, + { + "z":"Web site archive" + } + ], + "ind1":"4", + "ind2":"0" + } + } + ] + } +] \ No newline at end of file diff --git a/test/parse.js b/test/parse.js index 07a3bf8..344510c 100644 --- a/test/parse.js +++ b/test/parse.js @@ -1,4 +1,5 @@ var parse = require('../lib/parse'); +var transform = require('../lib/transform'); var fs = require('fs'); describe('parse', function () { @@ -136,4 +137,14 @@ describe('parse', function () { }); }); + it('should parse marc-in-json with multiple records', function(done) { + fs.readFile('test/data/collection.json', function(err, data) { + parse(data.toString(), {fromFormat: 'json'}, function(err, records) { + expect(records.length).equal(2); + expect(records[1].leader.marshal()).equal('01832cmma 2200349 a 4500'); + }); + done(); + }); + }); + });