Commit 36462a7d authored by Chaillet Maxime's avatar Chaillet Maxime

Fix old tests. It fixes #85

parent 31c344f3
Pipeline #37613 passed with stages
in 18 seconds
// Karma configuration
// Generated on Thu Oct 11 2018 23:09:22 GMT+0200 (CEST)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "",
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "",
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ["jasmine", "browserify", "jquery-3.4.0"],
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ["jasmine", "browserify", "jquery-3.4.0"],
// list of files / patterns to load in the browser
files: [
"bower_components/dustjs-linkedin/dist/dust-full.js",
"bower_components/lodash/lodash.js",
"bower_components/moment/moment.js",
"src/*.js",
"templates/welcome_tpl.js",
"tests/*js"
],
// list of files / patterns to load in the browser
files: [
"bower_components/dustjs-linkedin/dist/dust-full.js",
"bower_components/lodash/lodash.js",
"bower_components/moment/moment.js",
"src/*.js",
"templates/welcome_tpl.js",
"tests/*js"
],
// list of files / patterns to exclude
exclude: [],
// list of files / patterns to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"tests/jsonExtractor.test.js": ["browserify"],
"tests/googleMetadataObject.test.js": ["browserify"],
"tests/welcomeTemplate.test.js": ["browserify"],
"templates/welcome_tpl.js": ["html2js"]
},
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"tests/jsonExtractor.test.js": ["browserify"],
"tests/googleMetadataObject.test.js": ["browserify"],
"tests/welcomeTemplate.test.js": ["browserify"],
"templates/welcome_tpl.js": ["html2js"]
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["progress"],
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha"],
// web server port
port: 9876,
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
//browsers: ['Firefox', 'Chrome'],
browsers: ["Firefox"],
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Firefox', 'Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};
......@@ -26,6 +26,7 @@
"karma-html2js-preprocessor": "^1.1.0",
"karma-jasmine": "^1.1.2",
"karma-jquery": "^0.2.4",
"karma-mocha-reporter": "^2.2.5",
"watchify": "^3.11.0"
},
"scripts": {
......
......@@ -32,4 +32,3 @@ DoiData.prototype.getAccessibilityStatus = function (resourceType, sessionDate,
console.log("Failed to determine whether the accessibility of the DOI.");
return "Accessibility status could not be determined";
};
describe("citation", () => {
describe("getDOIRegistrationYear", () => {
it("Returns the year for experimental session", () => {
let actualDoiData = {
resourceType: "experimental session resource type",
sessionDate: "2017-12-31",
publiclyAccessibleYear: "2018"
};
describe("getDOIRegistrationYear", () => {
it("Returns the year for experimental session", () => {
let actualDoiData = {
resourceType: "experimental session resource type",
sessionDate: "2017-12-31",
publiclyAccessibleYear: "2018"
};
let expectedYear = 2017;
let myCitation = new Citation();
expect(myCitation.getDOIRegistrationYear(actualDoiData)).toEqual(
expectedYear
);
});
let expectedYear = 2017;
let myCitation = new Citation();
expect(myCitation.getDOIRegistrationYear(actualDoiData)).toEqual(
expectedYear
);
});
it("Returns the year for datacollection session", () => {
// thre is no sessionDate for this kind of DOI
let actualDoiData = {
resourceType: "dataset collection resource type",
publiclyAccessibleYear: "2018"
};
it("Returns the year for datacollection session", () => {
// thre is no sessionDate for this kind of DOI
let actualDoiData = {
resourceType: "dataset collection resource type",
publiclyAccessibleYear: "2018"
};
let expectedYear = 2018;
let myCitation = new Citation();
expect(myCitation.getDOIRegistrationYear(actualDoiData)).toEqual(
expectedYear
);
});
let expectedYear = "2018";
let myCitation = new Citation();
expect(myCitation.getDOIRegistrationYear(actualDoiData)).toEqual(
expectedYear
);
});
it("Returns an empty string when sessionDate is not provided", () => {
let actualDoiData = {};
it("Returns an empty string when sessionDate is not provided", () => {
let actualDoiData = {};
let expectedYear = "";
let myCitation = new Citation();
expect(myCitation.getDOIRegistrationYear(actualDoiData)).toEqual(
expectedYear
);
let expectedYear = "";
let myCitation = new Citation();
expect(myCitation.getDOIRegistrationYear(actualDoiData)).toEqual(
expectedYear
);
});
});
});
});
......@@ -12,7 +12,7 @@ describe('DoiData', () => {
let doiData = new DoiData();
let actualReourceType = CONSTANTS.ES_RESOURCE_TYPE;
let actualSessionDate = "2017-01-01"
let actualPubliclyAccessibleYear = "2020"
let actualPubliclyAccessibleYear = "2100"
expect(doiData.getAccessibilityStatus(actualReourceType, actualSessionDate, actualPubliclyAccessibleYear)).toEqual("Restricted access");
})
......
describe("WelcomeTemplate", () => {
it("Link to all ESRF DOIs", () => {
dust.renderSource(
window.__html__["templates/welcome_tpl.js"],
{},
(err, out) => {
$("body").append(out);
let a = $("a:contains('List all ESRF DOIs')")[0];
expect(a.href).toEqual(
"https://search.datacite.org/works?query=10.15151%2F*"
it("Link to all ESRF DOIs", () => {
dust.renderSource(
window.__html__["templates/welcome_tpl.js"],
{},
(err, out) => {
$("body").append(out);
let a = $("a:contains('List all ESRF DOIs')")[0];
expect(a.href).toEqual(
"https://search.datacite.org/works?query=10.15151%2F*"
);
}
);
}
);
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment