diff --git a/js/src/alert.js b/js/src/alert.js
index 69e2e36..4096c37 100644
--- a/js/src/alert.js
+++ b/js/src/alert.js
@@ -40,6 +40,7 @@ export default class uAlert {
this.hasButton = typeof options.hasButton !== 'undefined' ? options.hasButton : this.autoClose === 0
this.fixedPosition = options.fixed || false;
const html = `
${message}
`;
+ /** @var HTMLElement */
this.box = uUtils.nodeFromHtml(html);
if (options.id) {
this.box.id = options.id;
diff --git a/js/test/api_gmaps.test.js b/js/test/api_gmaps.test.js
index 8187cc0..d64c9a5 100644
--- a/js/test/api_gmaps.test.js
+++ b/js/test/api_gmaps.test.js
@@ -52,7 +52,7 @@ describe('Google Maps map API tests', () => {
it('should timeout initialization of map engine', (done) => {
// given
- spyOn(uUtils, 'loadScript').and.returnValue(Promise.resolve());
+ spyOn(uUtils, 'loadScript').and.resolveTo();
// when
api.init()
.then(() => done.fail('resolve callback called'))
@@ -64,7 +64,7 @@ describe('Google Maps map API tests', () => {
it('should fail loading script', (done) => {
// given
- spyOn(uUtils, 'loadScript').and.returnValue(Promise.reject(Error('script loading error')));
+ spyOn(uUtils, 'loadScript').and.rejectWith(Error('script loading error'));
// when
api.init()
.then(() => done.fail('resolve callback called'))
@@ -76,7 +76,7 @@ describe('Google Maps map API tests', () => {
it('should load and initialize api scripts', (done) => {
// given
- spyOn(uUtils, 'loadScript').and.returnValue(Promise.resolve());
+ spyOn(uUtils, 'loadScript').and.resolveTo();
spyOn(api, 'initMap');
config.googleKey = 'key1234567890';
// when
@@ -109,7 +109,7 @@ describe('Google Maps map API tests', () => {
it('should initialize map engine without Google API key', (done) => {
// given
spyOn(google.maps, 'Map').and.callThrough();
- spyOn(uUtils, 'loadScript').and.returnValue(Promise.resolve());
+ spyOn(uUtils, 'loadScript').and.resolveTo();
// when
api.init()
.then(() => {
@@ -124,7 +124,7 @@ describe('Google Maps map API tests', () => {
it('should fail with authorization error', (done) => {
// given
- spyOn(uUtils, 'loadScript').and.returnValue(Promise.resolve());
+ spyOn(uUtils, 'loadScript').and.resolveTo();
lang._.and.returnValue('authfailure');
// when
api.init()
@@ -140,7 +140,7 @@ describe('Google Maps map API tests', () => {
it('should show alert if authorization error occurs after initialization', (done) => {
// given
spyOn(google.maps, 'Map').and.callThrough();
- spyOn(uUtils, 'loadScript').and.returnValue(Promise.resolve());
+ spyOn(uUtils, 'loadScript').and.resolveTo();
lang._.and.returnValue('authfailure');
// when
api.init()
diff --git a/js/test/configdialogmodel.test.js b/js/test/configdialogmodel.test.js
index de912e0..90e9143 100644
--- a/js/test/configdialogmodel.test.js
+++ b/js/test/configdialogmodel.test.js
@@ -135,7 +135,7 @@ describe('ConfigDialogModel tests', () => {
it('should save config on positive button clicked', (done) => {
// given
spyOn(cm, 'validate').and.returnValue(true);
- spyOn(config, 'save').and.returnValue(Promise.resolve());
+ spyOn(config, 'save').and.resolveTo();
cm.init();
const button = cm.dialog.element.querySelector("[data-bind='onSave']");
// when
@@ -152,7 +152,7 @@ describe('ConfigDialogModel tests', () => {
it('should set priority layer on save', (done) => {
// given
spyOn(cm, 'validate').and.returnValue(true);
- spyOn(config, 'save').and.returnValue(Promise.resolve());
+ spyOn(config, 'save').and.resolveTo();
cm.init();
cm.model.layerId = '1';
const button = cm.dialog.element.querySelector("[data-bind='onSave']");
diff --git a/js/test/position.test.js b/js/test/position.test.js
index 02dc174..cc17142 100644
--- a/js/test/position.test.js
+++ b/js/test/position.test.js
@@ -243,7 +243,7 @@ describe('Position tests', () => {
it('should delete image on server', (done) => {
// given
- spyOn(uPosition, 'update').and.returnValue(Promise.resolve());
+ spyOn(uPosition, 'update').and.resolveTo();
const position = uPosition.fromJson(jsonPosition);
// when
position.imageDelete()
@@ -259,7 +259,7 @@ describe('Position tests', () => {
// given
const newImage = 'new_image.jpg';
const imageFile = 'imageFile';
- spyOn(uPosition, 'update').and.returnValue(Promise.resolve({ image: newImage }));
+ spyOn(uPosition, 'update').and.resolveTo({ image: newImage });
const position = uPosition.fromJson(jsonPosition);
// when
position.imageAdd(imageFile);
diff --git a/js/test/positiondialogmodel.test.js b/js/test/positiondialogmodel.test.js
index f95c61f..1fb44c3 100644
--- a/js/test/positiondialogmodel.test.js
+++ b/js/test/positiondialogmodel.test.js
@@ -41,8 +41,8 @@ describe('PositionDialogModel tests', () => {
track.positions[positionIndex].comment = comment;
state.currentTrack = track;
dm = new PositionDialogModel(state, positionIndex);
- spyOn(track.positions[positionIndex], 'save').and.returnValue(Promise.resolve());
- spyOn(track.positions[positionIndex], 'delete').and.returnValue(Promise.resolve());
+ spyOn(track.positions[positionIndex], 'save').and.resolveTo();
+ spyOn(track.positions[positionIndex], 'delete').and.resolveTo();
spyOn(uObserve, 'forceUpdate');
});
diff --git a/js/test/trackdialogmodel.test.js b/js/test/trackdialogmodel.test.js
index f7deca7..ff15d6c 100644
--- a/js/test/trackdialogmodel.test.js
+++ b/js/test/trackdialogmodel.test.js
@@ -39,8 +39,8 @@ describe('TrackDialogModel tests', () => {
mockVM = { state: new uState(), onTrackDeleted: {} };
dm = new TrackDialogModel(mockVM);
dm.track = TrackFactory.getTrack();
- spyOn(dm.track, 'delete').and.returnValue(Promise.resolve());
- spyOn(dm.track, 'saveMeta').and.returnValue(Promise.resolve());
+ spyOn(dm.track, 'delete').and.resolveTo();
+ spyOn(dm.track, 'saveMeta').and.resolveTo();
spyOn(dm.track, 'setName');
spyOn(uAlert, 'error');
});
diff --git a/js/test/userdialogmodel.test.js b/js/test/userdialogmodel.test.js
index cf0ac8a..bb2ad42 100644
--- a/js/test/userdialogmodel.test.js
+++ b/js/test/userdialogmodel.test.js
@@ -45,12 +45,12 @@ describe('UserDialogModel tests', () => {
dialogType = 'add';
dm = new UserDialogModel(mockVM, dialogType);
dm.user = new uUser(1, 'testUser');
- spyOn(dm.user, 'delete').and.returnValue(Promise.resolve());
- spyOn(dm.user, 'setPassword').and.returnValue(Promise.resolve());
+ spyOn(dm.user, 'delete').and.resolveTo();
+ spyOn(dm.user, 'setPassword').and.resolveTo();
spyOn(dm.user, 'modify').and.callThrough();
- spyOn(uUser, 'update').and.returnValue(Promise.resolve());
- spyOn(auth.user, 'setPassword').and.returnValue(Promise.resolve());
- spyOn(uUser, 'add').and.returnValue(Promise.resolve(newUser));
+ spyOn(uUser, 'update').and.resolveTo();
+ spyOn(auth.user, 'setPassword').and.resolveTo();
+ spyOn(uUser, 'add').and.resolveTo(newUser);
spyOn(config, 'validPassStrength').and.returnValue(true);
spyOn(uAlert, 'error');
});