Skip to content

Commit fa34bdf

Browse files
committed
add test to make sure getJsonResource function is checking for 'Solidus' string
1 parent d6e298a commit fa34bdf

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

background.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ function notifyDevtools(msgType, payload) {
4040
});
4141
}
4242

43+
function isSolidus(xpbHeader) {
44+
return xpbHeader.match(/Solidus/i);
45+
}
46+
4347
function getJsonResource(tabID) {
4448
chrome.tabs.get(tabID, function(tab) {
4549
var jsonResourceURL = tab.url+'.json';
@@ -48,7 +52,7 @@ function getJsonResource(tabID) {
4852
xhr.onreadystatechange = function() {
4953
if (xhr.readyState !== 4) return; //quickly return if not complete request
5054
var xpbHeader = xhr.getResponseHeader('X-Powered-By') || 'unknown';
51-
if (!xpbHeader.match(/Solidus/i)) { //quickly return if not solidus
55+
if (!isSolidus(xpbHeader)) { //quickly return if not solidus
5256
notifyDevtools('error', 'No Solidus header detected.');
5357
notifyDevtools('status', '<b>not</b> running Solidus 0.1.7 or greater');
5458
notifyDevtools('action', 'shutdown');

tests/spec/basic.spec.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
describe("A suite", function() {
2-
it("contains spec with an expectation", function() {
3-
expect(true).toBe(true);
1+
describe("Getting page context JSON", function() {
2+
it("Checks that header contains 'Solidus'", function() {
3+
var headerValue = isSolidus('Solidus');
4+
expect(headerValue).toBe(true);
45
});
5-
});
6+
});

0 commit comments

Comments
 (0)