it('malformed record payload', function() { metastamp.metastampDomain({}, myTimestamp, null); metastamp.metastampDomain(null, myTimestamp, null); metastamp.metastampDomain({ data: {} }, myTimestamp, null); metastamp.metastampDomain(undefined, myTimestamp, null); });
_.each(files, function(file) { var result; callCount++; var path = directory + '/' + file; var contents = fs.readFileSync(path); log.debug('have contents of ' + path); try { contents = JSON.parse(contents); log.debug('contents parsed'); expect(contents).not.toBeUndefined(); expect(contents.data).not.toBeUndefined(); expect(contents.data.items).not.toBeUndefined(); log.debug('generating metastamp'); result = metastamp.metastampDomain(contents, myTimestamp, null); } catch (e) { expect(e).toBeUndefined(); console.log('metastamp-spec.js'); console.log('File ' + path + ' encountered an error'); console.log(e); } expect(result.icn).toBeDefined(); expect(result.stampTime).toBe(myTimestamp); expect(result.sourceMetaStamp).not.toEqual({}); //more specific tests require knowledge of the file contents });
it('supplied ICN', function() { var myICN = '123456V7789'; var result = metastamp.metastampDomain(allergySubset, myTimestamp, myICN); expect(result.icn).toBe(myICN); expect(result.sourceMetaStamp['9E7A'].domainMetaStamp.allergy).toBeDefined(); expect(result.sourceMetaStamp['9E7A'].domainMetaStamp.allergy.domain).toBeDefined(); expect(result.sourceMetaStamp['9E7A'].domainMetaStamp.allergy.domain).toBe('allergy'); });
it('no callback provided', function() { var retValue = metastamp.metastampDomain(allergySubset); expect(retValue).toBeDefined(); });
it('malformed timestamp', function() { metastamp.metastampDomain({}, 'myTimestamp', null); });