-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #436 from simphony/add_view_tests
Add javascript tests for the Vue objects
- Loading branch information
Showing
7 changed files
with
179 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
define([ | ||
"home/models", | ||
"home/views/application_list_view", | ||
"components/vue/dist/vue", | ||
"vue/filters" | ||
], function (models, application_list_view, Vue) { | ||
"use strict"; | ||
|
||
QUnit.module("home.app_list_view"); | ||
QUnit.test("rendering list", function (assert) { | ||
var done = assert.async(); | ||
|
||
var model = new models.ApplicationListModel(); | ||
var app_list_view = new application_list_view.ApplicationListView({ | ||
data: function() { return { model: model }; } | ||
}).$mount(); | ||
|
||
assert.ok(model.loading); | ||
assert.equal( | ||
app_list_view.$el.querySelector("#loading-spinner").style.display, | ||
"" | ||
); | ||
|
||
model.update().done(function() { Vue.nextTick(function() { | ||
assert.equal( | ||
app_list_view.$el.querySelector("#no-app-msg").style.display, | ||
"none" | ||
); | ||
assert.equal( | ||
app_list_view.$el.querySelector("#loading-spinner").style.display, | ||
"none" | ||
); | ||
assert.equal( | ||
app_list_view.$el.querySelector("#applistentries").children.length, | ||
model.app_list.length | ||
); | ||
|
||
done(); | ||
})}); | ||
}); | ||
|
||
QUnit.test("rendering nothing in the list", function (assert) { | ||
var done = assert.async(); | ||
|
||
var model = new models.ApplicationListModel(); | ||
var app_list_view = new application_list_view.ApplicationListView({ | ||
data: function() { return { model: model }; } | ||
}).$mount(); | ||
|
||
model.loading = false; | ||
|
||
Vue.nextTick(function() { | ||
assert.equal( | ||
app_list_view.$el.querySelector("#no-app-msg").style.display, | ||
"" | ||
); | ||
assert.equal( | ||
app_list_view.$el.querySelector("#loading-spinner").style.display, | ||
"none" | ||
); | ||
assert.equal( | ||
app_list_view.$el.querySelector("#applistentries").children.length, | ||
0 | ||
); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
QUnit.test("search form", function (assert) { | ||
var done = assert.async(); | ||
|
||
var model = new models.ApplicationListModel(); | ||
var app_list_view = new application_list_view.ApplicationListView({ | ||
data: function() { return { model: model }; } | ||
}).$mount(); | ||
|
||
model.update().done(function() { Vue.nextTick(function() { | ||
assert.notEqual(app_list_view.visible_list.length, 0); | ||
|
||
app_list_view.search_input = "heho"; | ||
|
||
Vue.nextTick(function() { | ||
assert.equal(app_list_view.visible_list.length, 0); | ||
assert.equal( | ||
app_list_view.$el.querySelector("input[name=q]").value, | ||
"heho" | ||
); | ||
|
||
done(); | ||
}) | ||
})}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
define([ | ||
"home/models", | ||
"home/views/application_view", | ||
"components/vue/dist/vue", | ||
"vue/filters" | ||
], function (models, application_view, Vue) { | ||
"use strict"; | ||
|
||
QUnit.module("home.app_view"); | ||
QUnit.test("rendering form", function (assert) { | ||
var done = assert.async(); | ||
|
||
var model = new models.ApplicationListModel(); | ||
var app_view = new application_view.ApplicationView({ | ||
data: function() { return { model: model }; } | ||
}).$mount(); | ||
|
||
model.update().done(function() { Vue.nextTick(function() { | ||
assert.equal(app_view.$el.children[0].tagName, 'DIV'); | ||
assert.ok(app_view.$el.children[0].classList.contains('row')); | ||
|
||
assert.equal( | ||
app_view.$el.querySelector('.box-title').innerHTML, | ||
model.app_list[0].app_data.image.ui_name | ||
); | ||
|
||
// Simulate application starting | ||
model.app_list[0].status = 'STARTING'; | ||
|
||
assert.equal( | ||
app_view.$el.querySelector('.box-title').innerHTML, | ||
model.app_list[0].app_data.image.ui_name | ||
); | ||
assert.equal( | ||
app_view.$el.querySelector('#app-description').innerHTML, | ||
model.app_list[0].app_data.image.description | ||
); | ||
|
||
done(); | ||
})}); | ||
}); | ||
|
||
QUnit.test("rendering iframe", function (assert) { | ||
var done = assert.async(); | ||
|
||
var model = new models.ApplicationListModel(); | ||
var app_view = new application_view.ApplicationView({ | ||
data: function() { return { model: model }; } | ||
}).$mount(); | ||
|
||
model.update().done(function() { | ||
// Simulate application running | ||
model.app_list[0].status = 'RUNNING'; | ||
model.app_list[0].app_data.container = {}; | ||
model.app_list[0].app_data.container.url_id = 'https://127.0.0.1:1234/'; | ||
|
||
Vue.nextTick(function() { | ||
assert.equal(app_view.$el.children[0].tagName, 'IFRAME'); | ||
|
||
// Render form again by selecting the other application which is stopped | ||
model.selected_index = 1; | ||
|
||
Vue.nextTick(function() { | ||
console.log(model.app_list[1].ui_name) | ||
assert.equal( | ||
app_view.$el.querySelector('.box-title').innerHTML, | ||
model.app_list[1].app_data.image.ui_name | ||
); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters