Permalink
Browse files

Merge pull request #14 from erikvold/4

adding a test for issue #4
  • Loading branch information...
autonome committed Dec 8, 2012
2 parents d40af24 + 96b945a commit 1f935ab2eb51d0df35833ffe47c73b6f854cee2c
Showing with 18 additions and 19 deletions.
  1. +17 −19 tests/test-main.js
  2. +1 −0 tests/tweaks-test-get-number.js
View
@@ -1,32 +1,30 @@
+"use strict";
+
const main = require("main");
+const { data } = require("self");
+const pageMod = require("page-mod");
+const tabs = require("tabs");
-exports.test_test_run = function(test) {
- test.pass("Unit test running!");
-};
+const testFolderURL = module.uri.split('test-main.js')[0];
exports.test_id = function(test) {
test.assert(require("self").id.length > 0);
};
-exports.test_url = function(test) {
- require("request").Request({
- url: "http://www.mozilla.org/",
- onComplete: function(response) {
- test.assertEqual(response.statusText, "OK");
- test.done();
- }
- }).get();
- test.waitUntilDone(20000);
-};
+exports.test_getNumber = function(test) {
+ test.waitUntilDone();
+ let url = "data:text/html;charset=utf-8,<title>Bug 123456: TEST</title>";
-exports.test_open_tab = function(test) {
- const tabs = require("tabs");
tabs.open({
- url: "http://www.mozilla.org/",
+ url: url,
onReady: function(tab) {
- test.assertEqual(tab.url, "http://www.mozilla.org/");
- test.done();
+ tab.attach({
+ contentScriptFile: [ data.url("tweaks.js"), testFolderURL + "tweaks-test-get-number.js"],
+ onMessage: function(msg) {
+ test.assertEqual(msg, 123456, "Bug 123456: works!");
+ test.done();
+ }
+ });
}
});
- test.waitUntilDone(20000);
};
@@ -0,0 +1 @@
+self.postMessage(getBugNumber(document.title));

0 comments on commit 1f935ab

Please sign in to comment.