Commit 073eafdc authored by Chaillet Maxime's avatar Chaillet Maxime

Add the licence field in the metadata object as recommended by Google. It...

Add the licence field in the metadata object as recommended by Google. It fixes icat/doi-landing-page#77
parent df764cde
Pipeline #14577 canceled with stages
...@@ -3,17 +3,13 @@ ...@@ -3,17 +3,13 @@
module.exports = function (config) { module.exports = function (config) {
config.set({ config.set({
// base path that will be used to resolve all patterns (eg. files, exclude) // base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '', basePath: '',
// frameworks to use // frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'browserify'], frameworks: ['jasmine', 'browserify'],
// list of files / patterns to load in the browser // list of files / patterns to load in the browser
files: [ files: [
'src/beamlineurl.js', 'src/beamlineurl.js',
...@@ -33,12 +29,10 @@ module.exports = function (config) { ...@@ -33,12 +29,10 @@ module.exports = function (config) {
'bower_components/moment/moment.js' 'bower_components/moment/moment.js'
], ],
// list of files / patterns to exclude // list of files / patterns to exclude
exclude: [ exclude: [
], ],
// preprocess matching files before serving them to the browser // preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: { preprocessors: {
...@@ -46,33 +40,28 @@ module.exports = function (config) { ...@@ -46,33 +40,28 @@ module.exports = function (config) {
'tests/googleMetadataObject.test.js': ['browserify'] 'tests/googleMetadataObject.test.js': ['browserify']
}, },
// test results reporter to use // test results reporter to use
// possible values: 'dots', 'progress' // possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter // available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'], reporters: ['progress'],
// web server port // web server port
port: 9876, port: 9876,
// enable / disable colors in the output (reporters and logs) // enable / disable colors in the output (reporters and logs)
colors: true, colors: true,
// level of logging // level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO, logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes // enable / disable watching file and executing tests whenever any file changes
autoWatch: true, autoWatch: true,
// start these browsers // start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Firefox', 'Chrome'], browsers: ['Firefox', 'Chrome'],
//browsers: ['Firefox'],
// Continuous Integration mode // Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits // if true, Karma captures browsers, runs the tests and exits
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @param {*} data * @param {*} data
*/ */
function GoogleMetadataObject(data) { function GoogleMetadataObject(data) {
this.data = data; this.data = JSON.parse(JSON.stringify(data)); //creates a copy of the data object
} }
/** /**
...@@ -33,5 +33,4 @@ GoogleMetadataObject.prototype.setDescription = function () { ...@@ -33,5 +33,4 @@ GoogleMetadataObject.prototype.setDescription = function () {
} else { } else {
console.log("[GoogleMetadataObject] - The data required by Google is missing the 'name' field. This is required by Google for indexing."); console.log("[GoogleMetadataObject] - The data required by Google is missing the 'name' field. This is required by Google for indexing.");
} }
} }
\ No newline at end of file
...@@ -26,10 +26,10 @@ describe("googleMetadataObject unit tests", () => { ...@@ -26,10 +26,10 @@ describe("googleMetadataObject unit tests", () => {
describe("setDescription", () => { describe("setDescription", () => {
it.each(resources.setDescription, '[setDescription: %s ]', ['aboutThisTest'], it.each(resources.setDescription, '[setDescription: %s ]', ['aboutThisTest'],
function (element, next) { function (element, next) {
let gmo2 = new GoogleMetadataObject(element.data); let gmo = new GoogleMetadataObject(element.data);
gmo2.setDescription(); gmo.setDescription();
expect(gmo2.getMetadata()).toEqual(element.expected); expect(gmo.getMetadata()).toEqual(element.expected);
next(); next();
}) })
}) })
......
...@@ -10,6 +10,7 @@ module.exports = { ...@@ -10,6 +10,7 @@ module.exports = {
], ],
setLicense: [ setLicense: [
{ {
aboutThisTest: 'it sets the expected license',
data: library.googleMetadata1, data: library.googleMetadata1,
expected: { expected: {
"@context": "http://schema.org", "@context": "http://schema.org",
...@@ -67,12 +68,13 @@ module.exports = { ...@@ -67,12 +68,13 @@ module.exports = {
"@type": "Organization", "@type": "Organization",
"name": "DataCite" "name": "DataCite"
}, },
license: "https://creativecommons.org/licenses/by/4.0" "license": "https://creativecommons.org/licenses/by/4.0"
} }
} }
], ],
setDescription: [ setDescription: [
{ {
aboutThisTest: 'description is a copy of the name',
data: library.googleMetadata1, data: library.googleMetadata1,
expected: { expected: {
"@context": "http://schema.org", "@context": "http://schema.org",
...@@ -130,7 +132,7 @@ module.exports = { ...@@ -130,7 +132,7 @@ module.exports = {
"@type": "Organization", "@type": "Organization",
"name": "DataCite" "name": "DataCite"
}, },
description: "Nanoscopic Metal Composition of Phagosomal Compartments during Engulfment of E. coli by Professional Phagocytes.", "description": "Nanoscopic Metal Composition of Phagosomal Compartments during Engulfment of E. coli by Professional Phagocytes.",
} }
} }
] ]
......
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