summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2015-06-26 12:14:17 -0700
committerPhilip Chimento <philip@endlessm.com>2015-06-26 12:14:17 -0700
commit2d93813e4577c2f7a61fd6f0be3824cdee6efca4 (patch)
tree41fd38f16006589cf7741e0e8bd5435b0a6537a5 /test
parent594efddff77fbdce3a85751d1a519c2f193236b5 (diff)
Add more error checking to testTranslate2
While debugging the issue in the previous test, this was useful in order to make tests actually abort if they failed, instead of waiting for the async callback to be called. [endlessm/eos-shell#2309]
Diffstat (limited to 'test')
-rw-r--r--test/webhelper/testTranslate2.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/test/webhelper/testTranslate2.js b/test/webhelper/testTranslate2.js
index ea695d6..6ce4776 100644
--- a/test/webhelper/testTranslate2.js
+++ b/test/webhelper/testTranslate2.js
@@ -100,10 +100,16 @@ describe('WebHelper2 translator', function () {
const MINIMAL_HTML = '<p name="translatable">Translate Me</p>';
function run_loop(html=MINIMAL_HTML) {
- webview.connect('load-changed', (webview, event) => {
+ let error_spy = jasmine.createSpy('error_spy');
+ webview.connect('load-failed', error_spy);
+ let id = webview.connect('load-changed', (webview, event) => {
if (event === WebKit2.LoadEvent.FINISHED) {
webhelper.translate_html(webview, null, (obj, res) => {
- webhelper.translate_html_finish(res);
+ expect(function () {
+ webhelper.translate_html_finish(res);
+ }).not.toThrow();
+ webview.disconnect(id);
+ expect(error_spy).not.toHaveBeenCalled();
Mainloop.quit('webhelper2');
});
}
@@ -133,7 +139,9 @@ describe('WebHelper2 translator', function () {
it('can cancel the translation operation', function (done) {
webhelper.set_gettext((s) => s);
- webview.connect('load-changed', (webview, event) => {
+ let error_spy = jasmine.createSpy('error_spy');
+ webview.connect('load-failed', error_spy);
+ let id = webview.connect('load-changed', (webview, event) => {
if (event === WebKit2.LoadEvent.FINISHED) {
let cancellable = new Gio.Cancellable();
cancellable.cancel();
@@ -141,6 +149,8 @@ describe('WebHelper2 translator', function () {
expect(function () {
webhelper.translate_html_finish(res);
}).toThrow();
+ webview.disconnect(id);
+ expect(error_spy).not.toHaveBeenCalled();
done();
});
}