From 4711f6eee4de35c05a86a07b31178483b4bfb064 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Wed, 14 Jun 2017 00:43:20 +0800 Subject: [PATCH] util: Import notifyError dynamically when needed For unit tests, it is best not to pull in UI related code. https://bugzilla.gnome.org/show_bug.cgi?id=783738 Part-of: --- js/misc/util.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/misc/util.js b/js/misc/util.js index 508c87d24..161733b5d 100644 --- a/js/misc/util.js +++ b/js/misc/util.js @@ -6,7 +6,6 @@ import Shell from 'gi://Shell'; import St from 'gi://St'; import GnomeDesktop from 'gi://GnomeDesktop'; -import * as Main from '../ui/main.js'; import {formatTime} from './dateUtils.js'; // http://daringfireball.net/2010/07/improved_regex_for_matching_urls @@ -184,8 +183,10 @@ export function trySpawnCommandLine(commandLine) { } function _handleSpawnError(command, err) { - let title = _('Execution of ā€œ%sā€ failed:').format(command); - Main.notifyError(title, err.message); + const title = _('Execution of ā€œ%sā€ failed:').format(command); + // Use dynamic import to not pull in UI related code in unit tests + import('../ui/main.js').then( + ({notifyError}) => notifyError(title, err.message)); } /**