mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
Add unit tests
This commit is contained in:

committed by
Romain Neutron

parent
f146d6725a
commit
848413dead
@@ -209,7 +209,6 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
foreach($fieldObjects as $field) {
|
foreach($fieldObjects as $field) {
|
||||||
$field->delete();
|
$field->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateField()
|
public function testCreateField()
|
||||||
|
@@ -4,6 +4,10 @@ require.config({
|
|||||||
specs: "tests/specs",
|
specs: "tests/specs",
|
||||||
chai: "../assets/chai/chai",
|
chai: "../assets/chai/chai",
|
||||||
fixtures: "../assets/js-fixtures/fixtures",
|
fixtures: "../assets/js-fixtures/fixtures",
|
||||||
|
sinon: "../assets/sinon/lib/sinon",
|
||||||
|
sinonSpy: "../assets/sinon/lib/sinon/spy",
|
||||||
|
sinonMock: "../assets/sinon/lib/sinon/mock",
|
||||||
|
sinonStub: "../assets/sinon/lib/sinon/stub",
|
||||||
app: "apps/admin/fields/app",
|
app: "apps/admin/fields/app",
|
||||||
jquery: "../include/jslibs/jquery-1.7.1",
|
jquery: "../include/jslibs/jquery-1.7.1",
|
||||||
jqueryui: "../include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min",
|
jqueryui: "../include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min",
|
||||||
@@ -14,12 +18,17 @@ require.config({
|
|||||||
bootstrap: "../skins/html5/bootstrap/js/bootstrap.min"
|
bootstrap: "../skins/html5/bootstrap/js/bootstrap.min"
|
||||||
},
|
},
|
||||||
shim: {
|
shim: {
|
||||||
twig: {
|
|
||||||
exports: "Twig"
|
|
||||||
},
|
|
||||||
bootstrap : ["jquery"],
|
bootstrap : ["jquery"],
|
||||||
jqueryui: {
|
jqueryui: {
|
||||||
deps: ["jquery"]
|
deps: ["jquery"]
|
||||||
|
},
|
||||||
|
sinonSpy: {
|
||||||
|
deps: ["sinon"],
|
||||||
|
exports: "sinon"
|
||||||
|
},
|
||||||
|
sinonMock: {
|
||||||
|
deps: ["sinon", "sinonSpy", "sinonStub"],
|
||||||
|
exports: "sinon"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -207,7 +207,7 @@ define([
|
|||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
var model = new FieldModel({"id": 1, "sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"});
|
var model = new FieldModel({"id": 1, "sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"});
|
||||||
|
|
||||||
this.view = new EditView({"model": model}).render();
|
this.view = new EditView({"model": model});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("render() should return the view object", function() {
|
it("render() should return the view object", function() {
|
||||||
@@ -266,5 +266,46 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Edge cases", function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
AdminFieldApp.fieldsCollection.add({"sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"});
|
||||||
|
AdminFieldApp.dcFieldsCollection.add({
|
||||||
|
"label": "Contributor",
|
||||||
|
"definition": "An entity responsible for making contributions to the resource.",
|
||||||
|
"URI": "http://dublincore.org/documents/dces/#contributor"
|
||||||
|
});
|
||||||
|
|
||||||
|
AdminFieldApp.saveView = new SaveView();
|
||||||
|
AdminFieldApp.fieldErrorView = new FieldErrorView();
|
||||||
|
AdminFieldApp.fieldListView = new ListItemView({
|
||||||
|
collection: AdminFieldApp.fieldsCollection,
|
||||||
|
el: AdminFieldApp.$leftBlock
|
||||||
|
});
|
||||||
|
// render views
|
||||||
|
AdminFieldApp.saveView.render();
|
||||||
|
AdminFieldApp.fieldListView.render();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should update edit view when clicking on single element", function() {
|
||||||
|
AdminFieldApp.fieldListView.itemViews[0].clickAction();
|
||||||
|
should.exist(AdminFieldApp.fieldEditView);
|
||||||
|
assert.equal(AdminFieldApp.fieldEditView.model, AdminFieldApp.fieldListView.collection.first(), 'model is updated');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should reorder collection on drop action", function() {
|
||||||
|
var ui = {item: {index: function() {return 2;}}};
|
||||||
|
AdminFieldApp.fieldListView.itemViews[0].dropAction({},ui);
|
||||||
|
assert.equal(AdminFieldApp.fieldListView.collection.last().get('sorter'), 2, 'model is updated');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should update collection when model change", function() {
|
||||||
|
AdminFieldApp.fieldListView.itemViews[0].clickAction();
|
||||||
|
AdminFieldApp.fieldEditView.model.set({
|
||||||
|
"name": "new name"
|
||||||
|
});
|
||||||
|
assert.equal(AdminFieldApp.fieldListView.collection.first().get('name'), "new name", 'model is updated');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user