-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,713 additions
and
311 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,35 +1,123 @@ | ||
describe("Control.BibliographicInformation", function () { | ||
var reader; | ||
var reader; var control; | ||
var options = { region: 'top.toolbar.left' }; | ||
|
||
beforeEach(function() { | ||
reader = cozy.reader(document.createElement('div'), { | ||
engine: 'mock', | ||
href: 'mock.epub', | ||
metadata: { | ||
doi: 'https://doi.org/10.0000/cozy.0000' | ||
} | ||
}); | ||
}); | ||
|
||
it("can be added to an unloaded reader", function () { | ||
new cozy.Control.BibliographicInformation(options).addTo(reader); | ||
}); | ||
|
||
it("can be added and use the default metadata via modal", function () { | ||
var control = new cozy.Control.BibliographicInformation(options).addTo(reader); | ||
reader.start(function() { | ||
happen.click(control._control); | ||
var selector = function(key) { | ||
return "dd.cozy-bib-info-value-" + key; | ||
}; | ||
|
||
var container = control._modal._container; | ||
var keys = [ 'title', 'creator', 'doi' ]; | ||
keys.forEach(function(key) { | ||
var expr = "dd.cozy-bib-info-value-" + key; | ||
var node = container.querySelector(expr); | ||
expect(node).not.to.be(null); | ||
expect(node.innerHTML).to.be(reader.metadata[key]); | ||
}) | ||
describe("it can work as expected", function() { | ||
beforeEach(function() { | ||
reader = cozy.reader(document.createElement('div'), { | ||
engine: 'mock', | ||
href: 'mock.epub', | ||
metadata: { | ||
doi: 'https://doi.org/10.0000/cozy.0000' | ||
} | ||
}); | ||
control = new cozy.Control.BibliographicInformation(options).addTo(reader); | ||
reader.start(function() { | ||
happen.click(control._control); | ||
}); | ||
}); | ||
}); | ||
|
||
it("title should be title", function() { | ||
var container = control._modal._container; | ||
var key; var expr; var node; | ||
|
||
key = 'title'; | ||
expr = selector(key); | ||
node = container.querySelector(expr); | ||
expect(node).to.not.be(null); | ||
expect(node.innerText).to.eql(reader.metadata[key]); | ||
}) | ||
|
||
it("creator should be creator", function() { | ||
var container = control._modal._container; | ||
var key; var expr; var node; | ||
|
||
key = 'creator'; | ||
expr = selector(key); | ||
node = container.querySelector(expr); | ||
expect(node).to.not.be(null); | ||
expect(node.innerText).to.eql(reader.metadata[key]); | ||
}) | ||
|
||
it("doi should be doi", function() { | ||
var container = control._modal._container; | ||
var key; var expr; var node; | ||
|
||
key = 'doi'; | ||
expr = selector(key); | ||
node = container.querySelector(expr); | ||
expect(node).to.not.be(null); | ||
expect(node.innerText).to.eql(reader.metadata[key]); | ||
}) | ||
|
||
it("pubdate should be abbreviated", function() { | ||
|
||
var container = control._modal._container; | ||
var key; var expr; var node; | ||
|
||
key = 'pubdate'; | ||
expr = selector(key); | ||
node = container.querySelector(expr); | ||
expect(node).to.not.be(null); | ||
expect(node.innerText).to.not.eql(reader.metadata[key]); | ||
expect(node.innerText).to.eql("2017"); | ||
}) | ||
}) | ||
|
||
|
||
describe("more date fun", function() { | ||
it("it can deal with MM-DD-YYYY", function() { | ||
reader = cozy.reader(document.createElement('div'), { | ||
engine: 'mock', | ||
href: 'mock.epub', | ||
metadata: { | ||
doi: 'https://doi.org/10.0000/cozy.0000', | ||
pubdate: '01-01-2015' | ||
} | ||
}); | ||
control = new cozy.Control.BibliographicInformation(options).addTo(reader); | ||
reader.start(function() { | ||
happen.click(control._control); | ||
}); | ||
|
||
var container = control._modal._container; | ||
var key; var expr; var node; | ||
|
||
key = 'pubdate'; | ||
expr = selector(key); | ||
node = container.querySelector(expr); | ||
expect(node).to.not.be(null); | ||
expect(node.innerText).to.eql("2015"); | ||
}) | ||
|
||
it("it can deal with YYYY", function() { | ||
reader = cozy.reader(document.createElement('div'), { | ||
engine: 'mock', | ||
href: 'mock.epub', | ||
metadata: { | ||
doi: 'https://doi.org/10.0000/cozy.0000', | ||
pubdate: '1998' | ||
} | ||
}); | ||
control = new cozy.Control.BibliographicInformation(options).addTo(reader); | ||
reader.start(function() { | ||
happen.click(control._control); | ||
}); | ||
|
||
var container = control._modal._container; | ||
var key; var expr; var node; | ||
|
||
key = 'pubdate'; | ||
expr = selector(key); | ||
node = container.querySelector(expr); | ||
expect(node).to.not.be(null); | ||
expect(node.innerText).to.eql("1998"); | ||
}) | ||
}) | ||
|
||
}); | ||
|
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 |
---|---|---|
@@ -1,50 +1,58 @@ | ||
describe("Control.Contents", function () { | ||
var reader; | ||
var reader; var control; | ||
var options = { region: 'top.toolbar.left' }; | ||
|
||
beforeEach(function() { | ||
reader = cozy.reader(document.createElement('div'), { | ||
engine: 'mock', | ||
href: 'mock.epub', | ||
describe("no skip link", function() { | ||
beforeEach(function() { | ||
reader = cozy.reader(document.createElement('div'), { | ||
engine: 'mock', | ||
href: 'mock.epub', | ||
}); | ||
|
||
control = new cozy.Control.Contents(options).addTo(reader); | ||
reader.start(function() { | ||
happen.click(control._control); | ||
}); | ||
}); | ||
}); | ||
|
||
it("can be added to an unloaded reader", function () { | ||
new cozy.Control.Contents(options).addTo(reader); | ||
}); | ||
|
||
it("contents panel will be constructed", function () { | ||
var control = new cozy.Control.Contents(options).addTo(reader); | ||
|
||
reader.start(function() { | ||
happen.click(control._control); | ||
|
||
it("contents panel will be constructed", function () { | ||
var div = control._modal._container; | ||
var n = div.querySelectorAll("a"); | ||
expect(node).not.to.be(0); | ||
var node = div.querySelectorAll("a"); | ||
expect(node.length).not.to.eql(0); | ||
}); | ||
|
||
it("skip link WILL NOT be created", function () { | ||
// expect(document.getElementById(control._id)).to.be(null); | ||
var link = document.querySelector("a[href='#action-" + control._id + "']"); | ||
expect(link).to.be(null); | ||
}); | ||
}); | ||
}) | ||
|
||
it("skip link WILL NOT be created", function () { | ||
var control = new cozy.Control.Contents(options).addTo(reader); | ||
describe("skip link", function() { | ||
var skip_div; | ||
|
||
reader.start(function() { | ||
expect(document.getElementById(control._id)).to.be(null); | ||
}); | ||
}); | ||
beforeEach(function() { | ||
var skip_div = document.createElement('div'); | ||
skip_div.setAttribute('class', 'skip'); | ||
document.body.appendChild(skip_div); | ||
|
||
it("skip link WILL be created", function () { | ||
var skip_div = document.createElement('div'); | ||
skip_div.setAttribute('class', 'skip'); | ||
document.body.appendChild(skip_div); | ||
reader = cozy.reader(document.createElement('div'), { | ||
engine: 'mock', | ||
href: 'mock.epub', | ||
}); | ||
|
||
var control = new cozy.Control.Contents({ region: options.region, skipLink: '.skip'}).addTo(reader); | ||
control = new cozy.Control.Contents({ region: options.region, skipLink: '.skip'}).addTo(reader); | ||
reader.start(function() { | ||
happen.click(control._control); | ||
}); | ||
}); | ||
|
||
reader.start(function() { | ||
expect(document.getElementById(control._id)).not.to.be(null); | ||
it("skip link WILL be created", function () { | ||
var link = document.querySelector("a[href='#action-" + control._id + "']"); | ||
expect(link).not.to.be(null); | ||
}); | ||
}); | ||
|
||
}) | ||
|
||
}); | ||
|
Oops, something went wrong.