This repository has been archived by the owner on Aug 17, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests to increase coverage (#56)
- Loading branch information
1 parent
3cc1279
commit c513061
Showing
7 changed files
with
172 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"esversion": 6, | ||
"node": "true", | ||
"mocha": "true" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// This software is free software. See AUTHORS and LICENSE for more | ||
// information on the copying conditions. | ||
|
||
"use strict"; | ||
|
||
const assert = require("chai").assert; | ||
const rules = require("../../lib/common/rules"); | ||
|
||
const entry = { | ||
"iliege_hefce_model": "not_specified", | ||
"gold_oa_options": "not_specified", | ||
"datestamp": "2014-12-15 22:09:36", | ||
"rights_holding": "not_mentioned", | ||
"status_changed": "2014-12-15 22:09:36", | ||
"repository_url": "http://preprints.acmac.uoc.gr/", | ||
"date_made_open": "not_mentioned", | ||
"waive_open_access": "not_specified", | ||
"maximal_embargo_waivable": "not_applicable", | ||
"policymaker_type": "research_org_subunit", | ||
"policymaker_url": "http://www.acmac.uoc.gr/index.php", | ||
"rights_retention_waivable": "not_applicable", | ||
"title": "ACMAC - Archimedes Center for Modeling, Analysis & Computation", | ||
"lastmod": "2015-07-24 08:29:49", | ||
"policy_colour": "black", | ||
"embargo_hum_soc": "not_specified", | ||
"type": "article", | ||
"policymaker_name": "ACMAC - Archimedes Center for Modeling, Analysis & Computation", | ||
"locus_of_deposit": "not_specified", | ||
"eprintid": 173, | ||
"country_inclusive": [ | ||
"un_geoscheme", | ||
150, | ||
39, | ||
300 | ||
], | ||
"can_deposit_be_waived": "not_specified", | ||
"rev_number": 8, | ||
"date_of_deposit": "not_specified", | ||
"making_deposit_open": "not_mentioned", | ||
"country_names": [ | ||
"Europe", | ||
"Southern Europe", | ||
"Greece" | ||
], | ||
"deposit_of_item": "not_specified", | ||
"mandate_content_types": [ | ||
"not_specified" | ||
], | ||
"metadata_visibility": "show", | ||
"open_licensing_conditions": "not_specified", | ||
"userid": 251, | ||
"uri": "http://roarmap.eprints.org/id/eprint/173", | ||
"embargo_sci_tech_med": "not_specified", | ||
"eprint_status": "archive", | ||
"journal_article_version": "author_final", | ||
"open_access_waivable": "not_specified", | ||
"country": 300, | ||
"dir": "disk0/00/00/01/73", | ||
"apc_funding": "not_mentioned" | ||
}; | ||
|
||
const rule = { | ||
field_id: 1024, | ||
compliant_values: {}, | ||
guidelines: ["3.2", "3.20"], | ||
}; | ||
|
||
describe("rules", () => { | ||
describe("evaluateRule", () => { | ||
it("throws Error if the input rule is invalid", () => { | ||
assert.throws((() => (rules.evaluateRule(rule, entry, | ||
"open_licensing_conditions", "req_cc_by"))), Error); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// This software is free software. See AUTHORS and LICENSE for more | ||
// information on the copying conditions. | ||
|
||
"use strict"; | ||
|
||
const assert = require("chai").assert; | ||
const scrape = require("../../lib/server/scrape"); | ||
|
||
describe("scrape", () => { | ||
|
||
describe("fetch", () => { | ||
|
||
it("deals with request.request() errors", (done) => { | ||
scrape.fetch("http://www.google.com/robots.txt", (error) => { | ||
assert.instanceOf(error, Error); | ||
done(); | ||
}, (options, callback) => { | ||
callback(new Error("xo")); | ||
}); | ||
}); | ||
|
||
it("deals with wrong response statuses", (done) => { | ||
scrape.fetch("http://www.google.com/robots.txt", (error) => { | ||
assert.instanceOf(error, Error); | ||
done(); | ||
}, (options, callback) => { | ||
callback(null, {statusCode: 400}); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe("jsdomWrap", () => { | ||
|
||
it("deals with fetch() errors", (done) => { | ||
scrape.jsdomWrap("http://www.google.com/robots.txt", (error) => { | ||
assert.instanceOf(error, Error); | ||
done(); | ||
}, (url, callback) => { | ||
callback(new Error("mm")); | ||
}, () => { | ||
throw new Error("xo"); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
}); |