Skip to content

Commit 41a0fcd

Browse files
committed
add unit test for isSolidus function
1 parent 407e818 commit 41a0fcd

5 files changed

Lines changed: 37 additions & 21 deletions

File tree

Gruntfile.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ module.exports = function(grunt) {
3333

3434
grunt.registerTask('default', ['jshint', 'jasmine']);
3535
grunt.registerTask('test', ['jshint', 'jasmine']);
36-
37-
//TODO: Add Jasmine tests to build task
38-
grunt.registerTask('build', ['jshint', 'run:crxmake']);
36+
grunt.registerTask('build', ['jshint', 'jasmine', 'run:crxmake']);
3937

4038
};

dist/devtools-solidus-0.1.0.crx

53 Bytes
Binary file not shown.

extension/background.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ function notifyDevtools(msgType, payload) {
4141
}
4242

4343
function isSolidus(xpbHeader) {
44-
return xpbHeader.match(/Solidus/i);
44+
if (xpbHeader.match(/Solidus/i)) {
45+
return true;
46+
} else {
47+
return false;
48+
}
4549
}
4650

4751
function getJsonResource(tabID) {

extension/devpanel.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@
1010

1111
var inspector;
1212

13-
var socket = io('http://localhost:8081');
14-
socket.on('connect', function(){
15-
socket.on('log', function(data){
16-
addToLog(data.message);
17-
});
18-
socket.on('disconnect', function(){
19-
document.querySelector('#serverlogs').innerHTML = 'Socket Disconnected';
20-
});
21-
});
13+
if (typeof io !== 'undefined') {
14+
var socket = io('http://localhost:8081');
15+
socket.on('connect', function(){
16+
socket.on('log', function(data){
17+
addToLog(data.message);
18+
});
19+
socket.on('disconnect', function(){
20+
document.querySelector('#serverlogs').innerHTML = 'Socket Disconnected';
21+
});
22+
});
23+
}
2224

2325
function processMainIncomingMessage(msg) {
2426
switch(msg.msgType) {
@@ -100,17 +102,23 @@ function updateStatus(status) { //Update status panel in footer
100102
}
101103

102104
function addToLog(msg) {
103-
var logContainer = document.querySelector('#serverlogs');
104-
logContainer.innerHTML += msg + '\n';
105-
logContainer.scrollTop = logContainer.scrollHeight;
105+
if (document.querySelector('#serverlogs')) {
106+
var logContainer = document.querySelector('#serverlogs');
107+
logContainer.innerHTML += msg + '\n';
108+
logContainer.scrollTop = logContainer.scrollHeight;
109+
}
106110
}
107111

108112
function clearLog() {
109113
document.querySelector('#serverlogs').innerHTML = '';
110114
}
111115

112-
window.onload = function() {
113-
var clearButton = document.querySelector('#logclear');
114-
clearButton.addEventListener('click', clearLog, false);
115-
$('#sidePanel').resizable({ minWidth: 120, handles: 'e'});
116-
};
116+
window.addEventListener('load', function() {
117+
if (document.querySelector('#logclear')) {
118+
var clearButton = document.querySelector('#logclear');
119+
clearButton.addEventListener('click', clearLog, false);
120+
}
121+
if (document.querySelector('#sidePanel')) {
122+
$('#sidePanel').resizable({ minWidth: 120, handles: 'e'});
123+
}
124+
}, false);

tests/spec/basic.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
describe("Jasmine", function() {
2+
it("successfully runs tests", function() {
3+
expect(true).toBe(true);
4+
});
5+
});
6+
17
describe("Getting page context JSON", function() {
28
it("Checks that header contains 'Solidus'", function() {
39
var headerValue = isSolidus('Solidus');

0 commit comments

Comments
 (0)