mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-09 11:03:17 +00:00
Fix tests
This commit is contained in:
@@ -12,7 +12,9 @@ module.exports = function(grunt) {
|
||||
'loadImages=false'
|
||||
]
|
||||
},
|
||||
all: ['www/scripts/tests/index.html']
|
||||
all: [
|
||||
'www/scripts/tests/*.html'
|
||||
]
|
||||
},
|
||||
qunit: {
|
||||
all: ['www/include/js/tests/*.html']
|
||||
|
@@ -146,7 +146,6 @@ class TaskManager implements ControllerProviderInterface
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function getScheduler(Application $app, Request $request)
|
||||
{
|
||||
if ($request->getRequestFormat() !== "json") {
|
||||
|
@@ -120,8 +120,6 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{#<script src="/assets/autobahnjs/autobahn.js"></script>#}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$("form[name='form-create-task'] select").bind("change", function() {
|
||||
|
@@ -9,14 +9,14 @@
|
||||
|
||||
define([
|
||||
"jquery",
|
||||
"jqueryui",
|
||||
"underscore",
|
||||
"backbone",
|
||||
"i18n",
|
||||
"common/multiviews",
|
||||
"apps/admin/fields/views/listRow",
|
||||
"apps/admin/fields/views/create"
|
||||
], function ($, jqueryui, _, Backbone, i18n, MultiViews, FieldListRowView, CreateView) {
|
||||
"apps/admin/fields/views/create",
|
||||
"jquery.ui"
|
||||
], function ($, _, Backbone, i18n, MultiViews, FieldListRowView, CreateView) {
|
||||
var FieldListView = Backbone.View.extend(_.extend({}, MultiViews, {
|
||||
events: {
|
||||
"keyup #live_search": "searchAction",
|
||||
|
@@ -51,4 +51,4 @@ require.config({
|
||||
deps: ["jquery.ui.widget"]
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@@ -12,7 +12,7 @@ require.config({
|
||||
baseUrl: "/scripts",
|
||||
paths: {
|
||||
jquery: "../assets/jquery/jquery",
|
||||
jqueryui: "../assets/jquery.ui/jquery-ui",
|
||||
"jquery.ui": "../assets/jquery.ui/jquery-ui",
|
||||
underscore: "../assets/underscore-amd/underscore",
|
||||
backbone: "../assets/backbone-amd/backbone",
|
||||
i18n: "../assets/i18next/i18next.amd-1.6.3",
|
||||
@@ -22,12 +22,12 @@ require.config({
|
||||
},
|
||||
shim: {
|
||||
bootstrap: ["jquery"],
|
||||
jqueryui: {
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.geonames": {
|
||||
deps: ['jquery', 'jqueryui'],
|
||||
exports: '$.fn.geocompleter'
|
||||
deps: ["jquery", "jquery.ui"],
|
||||
exports: "$.fn.geocompleter"
|
||||
},
|
||||
"common/geonames": {
|
||||
deps: ["jquery.geonames"]
|
||||
|
90
www/scripts/tests/admin.html
Normal file
90
www/scripts/tests/admin.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Mocha Spec Runner</title>
|
||||
<link rel="stylesheet" href="./../../../tmp-assets/mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="./../../../tmp-assets/mocha/mocha.js"></script>
|
||||
<script src="./../../../tmp-assets/sinonjs/sinon.js"></script>
|
||||
<script src="../../assets/requirejs/require.js"></script>
|
||||
<script type="text/javascript">
|
||||
require.config({
|
||||
baseUrl: "../../scripts",
|
||||
paths: {
|
||||
"chai" : "../../tmp-assets/chai/chai",
|
||||
"fixtures": "../../tmp-assets/js-fixtures/fixtures",
|
||||
"jquery": "../assets/jquery/jquery",
|
||||
"backbone": "../assets/backbone-amd/backbone",
|
||||
"i18n": "../assets/i18next/i18next.amd-1.6.3",
|
||||
"bootstrap": "../assets/bootstrap/js/bootstrap.min",
|
||||
"sinonchai": "../../tmp-assets/sinon-chai/lib/sinon-chai",
|
||||
"squire": "../../tmp-assets/squire/src/Squire",
|
||||
"jquery.ui": "../assets/jquery.ui/jquery-ui",
|
||||
"underscore": "../assets/underscore-amd/underscore",
|
||||
"jquery.ui.widget": "../assets/jquery-file-upload/jquery.ui.widget",
|
||||
"jquery.cookie": "../assets/jquery.cookie/jquery.cookie",
|
||||
"jquery.treeview": "../assets/jquery.treeview/jquery.treeview",
|
||||
"jquery.tooltip": "../assets/jquery.tooltip/jquery.tooltip",
|
||||
"blueimp.loadimage" : "../assets/blueimp-load-image/load-image",
|
||||
"jfu.iframe-transport": "../assets/jquery-file-upload/jquery.iframe-transport",
|
||||
"jfu.fileupload": "../assets/jquery-file-upload/jquery.fileupload"
|
||||
},
|
||||
shim: {
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.treeview": {
|
||||
deps: ['jquery', 'jquery.cookie'],
|
||||
exports: '$.fn.treeview'
|
||||
},
|
||||
bootstrap:{
|
||||
deps: ['jquery']
|
||||
},
|
||||
"jquery.cookie": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.cookie'
|
||||
},
|
||||
"jquery.tooltip": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.tooltip'
|
||||
},
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.ui.widget": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jfu.fileupload": {
|
||||
deps: ["jquery.ui.widget"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mocha.setup({
|
||||
ui: "bdd",
|
||||
ignoreLeaks: false,
|
||||
globals: ['ab']
|
||||
});
|
||||
|
||||
console = window.console || function () {};
|
||||
|
||||
window.notrack = true;
|
||||
|
||||
window.runMocha = function () {
|
||||
if (window.mochaPhantomJS) {
|
||||
mochaPhantomJS.run();
|
||||
} else {
|
||||
mocha.run();
|
||||
}
|
||||
};
|
||||
require([
|
||||
'tests/specs/admin/fields',
|
||||
'tests/specs/admin/taskmanager',
|
||||
'tests/specs/admin/main'
|
||||
], window.runMocha);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,4 +0,0 @@
|
||||
define(["chai"], function (shai) {
|
||||
window.expect = shai.expect;
|
||||
window.assert = shai.assert;
|
||||
});
|
@@ -1,28 +0,0 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Mocha Spec Runner</title>
|
||||
<link rel="stylesheet" href="./../../../tmp-assets/mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="./../../../tmp-assets/mocha/mocha.js"></script>
|
||||
<script src="./../../../tmp-assets/sinonjs/sinon.js"></script>
|
||||
<script src="../../assets/requirejs/require.js"></script>
|
||||
<script src="../../scripts/tests/main.js"></script>
|
||||
<script>
|
||||
require([
|
||||
// 'tests/baseTest',
|
||||
// 'specs/admin/fields',
|
||||
// 'specs/admin/taskmanager',
|
||||
'specs/admin/main',
|
||||
// 'specs/login/home',
|
||||
// 'specs/models',
|
||||
// 'specs/validator',
|
||||
// 'specs/websockets/connection',
|
||||
// 'specs/websockets/subscriberManager'
|
||||
], runMocha);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
88
www/scripts/tests/login.html
Normal file
88
www/scripts/tests/login.html
Normal file
@@ -0,0 +1,88 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Mocha Spec Runner</title>
|
||||
<link rel="stylesheet" href="./../../../tmp-assets/mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="./../../../tmp-assets/mocha/mocha.js"></script>
|
||||
<script src="./../../../tmp-assets/sinonjs/sinon.js"></script>
|
||||
<script src="../../assets/requirejs/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
baseUrl: "../../scripts",
|
||||
paths: {
|
||||
"chai" : "../../tmp-assets/chai/chai",
|
||||
"fixtures": "../../tmp-assets/js-fixtures/fixtures",
|
||||
"jquery": "../assets/jquery/jquery",
|
||||
"backbone": "../assets/backbone-amd/backbone",
|
||||
"i18n": "../assets/i18next/i18next.amd-1.6.3",
|
||||
"bootstrap": "../assets/bootstrap/js/bootstrap.min",
|
||||
"sinonchai": "../../tmp-assets/sinon-chai/lib/sinon-chai",
|
||||
"squire": "../../tmp-assets/squire/src/Squire",
|
||||
"jquery.ui": "../assets/jquery.ui/jquery-ui",
|
||||
"underscore": "../assets/underscore-amd/underscore",
|
||||
"jquery.ui.widget": "../assets/jquery-file-upload/jquery.ui.widget",
|
||||
"jquery.cookie": "../assets/jquery.cookie/jquery.cookie",
|
||||
"jquery.treeview": "../assets/jquery.treeview/jquery.treeview",
|
||||
"jquery.tooltip": "../assets/jquery.tooltip/jquery.tooltip",
|
||||
"blueimp.loadimage" : "../assets/blueimp-load-image/load-image",
|
||||
"jfu.iframe-transport": "../assets/jquery-file-upload/jquery.iframe-transport",
|
||||
"jfu.fileupload": "../assets/jquery-file-upload/jquery.fileupload"
|
||||
},
|
||||
shim: {
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.treeview": {
|
||||
deps: ['jquery', 'jquery.cookie'],
|
||||
exports: '$.fn.treeview'
|
||||
},
|
||||
bootstrap:{
|
||||
deps: ['jquery']
|
||||
},
|
||||
"jquery.cookie": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.cookie'
|
||||
},
|
||||
"jquery.tooltip": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.tooltip'
|
||||
},
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.ui.widget": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jfu.fileupload": {
|
||||
deps: ["jquery.ui.widget"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mocha.setup({
|
||||
ui: "bdd",
|
||||
ignoreLeaks: false,
|
||||
globals: ['ab']
|
||||
});
|
||||
|
||||
console = window.console || function () {};
|
||||
|
||||
window.notrack = true;
|
||||
|
||||
window.runMocha = function () {
|
||||
if (window.mochaPhantomJS) {
|
||||
mochaPhantomJS.run();
|
||||
} else {
|
||||
mocha.run();
|
||||
}
|
||||
};
|
||||
require([
|
||||
'tests/specs/login/home'
|
||||
], window.runMocha);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,72 +0,0 @@
|
||||
require.config({
|
||||
baseUrl: "../../scripts",
|
||||
paths: {
|
||||
specs: "tests/specs",
|
||||
chai: "../../tmp-assets/chai/chai",
|
||||
fixtures: "../../tmp-assets/js-fixtures/fixtures",
|
||||
jquery: "../assets/jquery/jquery",
|
||||
jqueryui: "../assets/jquery.ui/jquery-ui",
|
||||
backbone: "../assets/backbone-amd/backbone",
|
||||
i18n: "../assets/i18next/i18next.amd-1.6.3",
|
||||
bootstrap: "../assets/bootstrap/js/bootstrap.min",
|
||||
sinonchai: "../../tmp-assets/sinon-chai/lib/sinon-chai",
|
||||
squire: "../../tmp-assets/squire/src/Squire",
|
||||
"jquery.ui": "../assets/jquery.ui/jquery-ui",
|
||||
underscore: "../assets/underscore-amd/underscore",
|
||||
"jquery.ui.widget": "../assets/jquery-file-upload/jquery.ui.widget",
|
||||
"jquery.cookie": "../assets/jquery.cookie/jquery.cookie",
|
||||
"jquery.treeview": "../assets/jquery.treeview/jquery.treeview",
|
||||
"jquery.tooltip": "../assets/jquery.tooltip/jquery.tooltip",
|
||||
"blueimp.loadimage" : "../assets/blueimp-load-image/load-image",
|
||||
"jfu.iframe-transport": "../assets/jquery-file-upload/jquery.iframe-transport",
|
||||
"jfu.fileupload": "../assets/jquery-file-upload/jquery.fileupload",
|
||||
},
|
||||
shim: {
|
||||
jqueryui: {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.treeview": {
|
||||
deps: ['jquery', 'jquery.cookie'],
|
||||
exports: '$.fn.treeview'
|
||||
},
|
||||
bootstrap:{
|
||||
deps: ['jquery']
|
||||
},
|
||||
"jquery.cookie": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.cookie'
|
||||
},
|
||||
"jquery.tooltip": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.tooltip'
|
||||
},
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.ui.widget": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jfu.fileupload": {
|
||||
deps: ["jquery.ui.widget"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mocha.setup({
|
||||
ui: "bdd",
|
||||
ignoreLeaks: true,
|
||||
globals: ['js-fixtures']
|
||||
});
|
||||
|
||||
console = window.console || function () {
|
||||
};
|
||||
|
||||
window.notrack = true;
|
||||
|
||||
var runMocha = function () {
|
||||
if (window.mochaPhantomJS) {
|
||||
mochaPhantomJS.run();
|
||||
} else {
|
||||
mocha.run();
|
||||
}
|
||||
};
|
88
www/scripts/tests/model.html
Normal file
88
www/scripts/tests/model.html
Normal file
@@ -0,0 +1,88 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Mocha Spec Runner</title>
|
||||
<link rel="stylesheet" href="./../../../tmp-assets/mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="./../../../tmp-assets/mocha/mocha.js"></script>
|
||||
<script src="./../../../tmp-assets/sinonjs/sinon.js"></script>
|
||||
<script src="../../assets/requirejs/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
baseUrl: "../../scripts",
|
||||
paths: {
|
||||
"chai" : "../../tmp-assets/chai/chai",
|
||||
"fixtures": "../../tmp-assets/js-fixtures/fixtures",
|
||||
"jquery": "../assets/jquery/jquery",
|
||||
"backbone": "../assets/backbone-amd/backbone",
|
||||
"i18n": "../assets/i18next/i18next.amd-1.6.3",
|
||||
"bootstrap": "../assets/bootstrap/js/bootstrap.min",
|
||||
"sinonchai": "../../tmp-assets/sinon-chai/lib/sinon-chai",
|
||||
"squire": "../../tmp-assets/squire/src/Squire",
|
||||
"jquery.ui": "../assets/jquery.ui/jquery-ui",
|
||||
"underscore": "../assets/underscore-amd/underscore",
|
||||
"jquery.ui.widget": "../assets/jquery-file-upload/jquery.ui.widget",
|
||||
"jquery.cookie": "../assets/jquery.cookie/jquery.cookie",
|
||||
"jquery.treeview": "../assets/jquery.treeview/jquery.treeview",
|
||||
"jquery.tooltip": "../assets/jquery.tooltip/jquery.tooltip",
|
||||
"blueimp.loadimage" : "../assets/blueimp-load-image/load-image",
|
||||
"jfu.iframe-transport": "../assets/jquery-file-upload/jquery.iframe-transport",
|
||||
"jfu.fileupload": "../assets/jquery-file-upload/jquery.fileupload"
|
||||
},
|
||||
shim: {
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.treeview": {
|
||||
deps: ['jquery', 'jquery.cookie'],
|
||||
exports: '$.fn.treeview'
|
||||
},
|
||||
bootstrap:{
|
||||
deps: ['jquery']
|
||||
},
|
||||
"jquery.cookie": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.cookie'
|
||||
},
|
||||
"jquery.tooltip": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.tooltip'
|
||||
},
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.ui.widget": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jfu.fileupload": {
|
||||
deps: ["jquery.ui.widget"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mocha.setup({
|
||||
ui: "bdd",
|
||||
ignoreLeaks: false,
|
||||
globals: ['ab']
|
||||
});
|
||||
|
||||
console = window.console || function () {};
|
||||
|
||||
window.notrack = true;
|
||||
|
||||
window.runMocha = function () {
|
||||
if (window.mochaPhantomJS) {
|
||||
mochaPhantomJS.run();
|
||||
} else {
|
||||
mocha.run();
|
||||
}
|
||||
};
|
||||
require([
|
||||
'tests/specs/models'
|
||||
], window.runMocha);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -2,18 +2,16 @@ define([
|
||||
'chai',
|
||||
'fixtures',
|
||||
'jquery',
|
||||
'squire',
|
||||
'apps/admin/main/app',
|
||||
'apps/admin/main/views/leftPanel',
|
||||
'apps/admin/main/views/rightPanel'
|
||||
], function (chai, fixtures, $, Squire, App, LeftPanel, RightPanel) {
|
||||
], function (chai, fixtures, $, App, LeftPanel, RightPanel) {
|
||||
var expect = chai.expect;
|
||||
var assert = chai.assert;
|
||||
var should = chai.should();
|
||||
|
||||
fixtures.path = 'fixtures';
|
||||
$("body").append(fixtures.read('admin/main/left-panel.html'));
|
||||
$("right-view").append(fixtures.read('admin/main/right-panel.html'));
|
||||
|
||||
App.create();
|
||||
|
||||
@@ -25,6 +23,14 @@ define([
|
||||
});
|
||||
|
||||
describe("Views", function () {
|
||||
beforeEach(function() {
|
||||
this.xhr = sinon.useFakeXMLHttpRequest();
|
||||
this.server = sinon.fakeServer.create();
|
||||
});
|
||||
afterEach(function() {
|
||||
this.xhr.restore();
|
||||
this.server.restore();
|
||||
});
|
||||
describe("leftView", function () {
|
||||
it("should throw an exception if 'event manager' is missing", function () {
|
||||
expect(function () {
|
||||
@@ -37,28 +43,23 @@ define([
|
||||
});
|
||||
|
||||
it("should make ajax request if we reload", function () {
|
||||
var xhr = sinon.useFakeXMLHttpRequest();
|
||||
var requests = [];
|
||||
xhr.onCreate = function (req) { requests.push(req); };
|
||||
this.xhr.onCreate = function (req) { requests.push(req); };
|
||||
|
||||
var leftP = new LeftPanel({eventManager : AdminApp.eventManager, treeUrl: "/admin/tree/"});
|
||||
leftP.reloadTree();
|
||||
|
||||
assert.equal(requests.length, 1);
|
||||
assert.equal(requests[0].url, "/admin/tree/");
|
||||
|
||||
xhr.restore();
|
||||
});
|
||||
|
||||
it("should make ajax request if we click link", function () {
|
||||
var xhr = sinon.useFakeXMLHttpRequest();
|
||||
var requests = [];
|
||||
xhr.onCreate = function (req) { requests.push(req); };
|
||||
this.xhr.onCreate = function (req) { requests.push(req); };
|
||||
|
||||
var leftP = new LeftPanel({eventManager : AdminApp.eventManager, el:$(".left-view"), treeUrl: "toto"});
|
||||
leftP.$('a[target=right]:first').trigger("click");
|
||||
assert.equal(requests.length, 1);
|
||||
xhr.restore();
|
||||
assert.ok(requests.length > 0);
|
||||
});
|
||||
|
||||
it("triggers right view", function () {
|
||||
@@ -67,18 +68,15 @@ define([
|
||||
trigger = true;
|
||||
});
|
||||
var leftP = new LeftPanel({eventManager : AdminApp.eventManager, el:$(".left-view"), treeUrl: "toto"});
|
||||
var rightP = new RightPanel({eventManager : AdminApp.eventManager, el:$(".right-view")});
|
||||
var server = sinon.fakeServer.create();
|
||||
leftP.activeTree();
|
||||
leftP.$('a[target=right]:first').trigger("click");
|
||||
server.requests[0].respond(
|
||||
this.server.requests[0].respond(
|
||||
200,
|
||||
{ "Content-Type": "application/json" },
|
||||
''
|
||||
);
|
||||
|
||||
assert.ok(trigger);
|
||||
server.restore();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -90,14 +88,21 @@ define([
|
||||
});
|
||||
|
||||
it("should make ajax request if we click link", function () {
|
||||
var xhr = sinon.useFakeXMLHttpRequest();
|
||||
var requests = [];
|
||||
xhr.onCreate = function (req) { requests.push(req); };
|
||||
|
||||
this.xhr.onCreate = function (req) { requests.push(req); };
|
||||
$(".right-view").html('<a href="toto">test</a>');
|
||||
var rightP = new RightPanel({eventManager : AdminApp.eventManager, el:$(".right-view")});
|
||||
rightP.$('a:not(.no-ajax)').trigger("click");
|
||||
assert.equal(requests.length, 1);
|
||||
xhr.restore();
|
||||
rightP.$('a').trigger('click');
|
||||
assert.ok(requests.length > 0);
|
||||
});
|
||||
|
||||
it("should make ajax request if we click form", function () {
|
||||
var requests = [];
|
||||
this.xhr.onCreate = function (req) { requests.push(req); };
|
||||
$(".right-view").html('<form method="POST" action="toto"></form>');
|
||||
var rightP = new RightPanel({eventManager : AdminApp.eventManager, el:$(".right-view")});
|
||||
rightP.$('form:first').trigger('submit');
|
||||
assert.ok(requests.length > 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -56,7 +56,7 @@ define([
|
||||
this.collection = new TaskCollection([]);
|
||||
this.view = new TasksView({
|
||||
collection: this.collection,
|
||||
el: AdminFieldApp.$tasksListView
|
||||
el: TaskManagerApp.$tasksListView
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ define([
|
||||
|
||||
this.view = new TasksView({
|
||||
collection: this.collection,
|
||||
el: AdminFieldApp.$tasksListView
|
||||
el: TaskManagerApp.$tasksListView
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -84,5 +84,3 @@ define([
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
@@ -9,50 +9,65 @@ define([
|
||||
var should = chai.should();
|
||||
chai.use(sinonchai);
|
||||
|
||||
describe("SubscriberManager", function () {
|
||||
var i;
|
||||
beforeEach(function () {
|
||||
var $this = this;
|
||||
$this.connection = {};
|
||||
$this.connection.subscribe = sinon.spy();
|
||||
$this.connection.unsubscribe = sinon.spy();
|
||||
$this.injector = new Squire();
|
||||
});
|
||||
(function () {
|
||||
describe("SubscriberManager", function () {
|
||||
beforeEach(function () {
|
||||
var $this = this;
|
||||
$this.connection = {};
|
||||
$this.connection.subscribe = sinon.spy();
|
||||
$this.connection.unsubscribe = sinon.spy();
|
||||
|
||||
it("should call subscribe", function () {
|
||||
var $this = this;
|
||||
$this.injector.mock(
|
||||
["common/websockets/connection"], $this.connection
|
||||
).require(['common/websockets/subscriberManager'], function(manager) {
|
||||
manager.register('topic');
|
||||
expect($this.connection.subscribe.should.have.callCount(1)).to.be.ok;
|
||||
assert.ok(manager.hasCallbacks());
|
||||
});
|
||||
|
||||
it("should call subscribe", function () {
|
||||
var $this = this;
|
||||
var injector = new Squire();
|
||||
injector.mock(
|
||||
["common/websockets/connection"], $this.connection
|
||||
).require(['common/websockets/subscriberManager'], function(manager) {
|
||||
manager.register('topic');
|
||||
expect($this.connection.subscribe.should.have.callCount(1)).to.be.ok;
|
||||
assert.ok(manager.hasCallbacks());
|
||||
});
|
||||
|
||||
try{
|
||||
injector.remove();
|
||||
} catch(e) {
|
||||
}
|
||||
});
|
||||
|
||||
it("should call unsubscribe", function () {
|
||||
var $this = this;
|
||||
var injector = new Squire();
|
||||
injector.mock(
|
||||
["common/websockets/connection"], $this.connection
|
||||
).require(['common/websockets/subscriberManager'], function(manager) {
|
||||
manager.register('topic');
|
||||
manager.unregister();
|
||||
expect($this.connection.unsubscribe.should.have.callCount(1)).to.be.ok;
|
||||
assert.ok(!manager.hasCallbacks());
|
||||
});
|
||||
try{
|
||||
injector.remove();
|
||||
} catch(e) {
|
||||
}
|
||||
});
|
||||
|
||||
it("should add callbacks", function () {
|
||||
var $this = this;
|
||||
var injector = new Squire();
|
||||
injector.mock(
|
||||
["common/websockets/connection"], $this.connection
|
||||
).require(['common/websockets/subscriberManager'], function(manager) {
|
||||
assert.ok(!manager.hasCallbacks());
|
||||
manager.pushCallback(function(){return null;});
|
||||
assert.ok(manager.hasCallbacks());
|
||||
});
|
||||
try{
|
||||
injector.remove();
|
||||
} catch(e) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should call unsubscribe", function () {
|
||||
var $this = this;
|
||||
$this.injector.mock(
|
||||
["common/websockets/connection"], $this.connection
|
||||
).require(['common/websockets/subscriberManager'], function(manager) {
|
||||
manager.register('topic');
|
||||
manager.unregister();
|
||||
expect($this.connection.unsubscribe.should.have.callCount(1)).to.be.ok;
|
||||
assert.ok(!manager.hasCallbacks());
|
||||
});
|
||||
});
|
||||
|
||||
it("should add callbacks", function () {
|
||||
var $this = this;
|
||||
$this.injector.mock(
|
||||
["common/websockets/connection"], $this.connection
|
||||
).require(['common/websockets/subscriberManager'], function(manager) {
|
||||
assert.ok(!manager.hasCallbacks());
|
||||
manager.pushCallback(function(){return null;});
|
||||
assert.ok(manager.hasCallbacks());
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
});
|
||||
|
||||
|
||||
|
88
www/scripts/tests/validator.html
Normal file
88
www/scripts/tests/validator.html
Normal file
@@ -0,0 +1,88 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Mocha Spec Runner</title>
|
||||
<link rel="stylesheet" href="./../../../tmp-assets/mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="./../../../tmp-assets/mocha/mocha.js"></script>
|
||||
<script src="./../../../tmp-assets/sinonjs/sinon.js"></script>
|
||||
<script src="../../assets/requirejs/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
baseUrl: "../../scripts",
|
||||
paths: {
|
||||
"chai" : "../../tmp-assets/chai/chai",
|
||||
"fixtures": "../../tmp-assets/js-fixtures/fixtures",
|
||||
"jquery": "../assets/jquery/jquery",
|
||||
"backbone": "../assets/backbone-amd/backbone",
|
||||
"i18n": "../assets/i18next/i18next.amd-1.6.3",
|
||||
"bootstrap": "../assets/bootstrap/js/bootstrap.min",
|
||||
"sinonchai": "../../tmp-assets/sinon-chai/lib/sinon-chai",
|
||||
"squire": "../../tmp-assets/squire/src/Squire",
|
||||
"jquery.ui": "../assets/jquery.ui/jquery-ui",
|
||||
"underscore": "../assets/underscore-amd/underscore",
|
||||
"jquery.ui.widget": "../assets/jquery-file-upload/jquery.ui.widget",
|
||||
"jquery.cookie": "../assets/jquery.cookie/jquery.cookie",
|
||||
"jquery.treeview": "../assets/jquery.treeview/jquery.treeview",
|
||||
"jquery.tooltip": "../assets/jquery.tooltip/jquery.tooltip",
|
||||
"blueimp.loadimage" : "../assets/blueimp-load-image/load-image",
|
||||
"jfu.iframe-transport": "../assets/jquery-file-upload/jquery.iframe-transport",
|
||||
"jfu.fileupload": "../assets/jquery-file-upload/jquery.fileupload"
|
||||
},
|
||||
shim: {
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.treeview": {
|
||||
deps: ['jquery', 'jquery.cookie'],
|
||||
exports: '$.fn.treeview'
|
||||
},
|
||||
bootstrap:{
|
||||
deps: ['jquery']
|
||||
},
|
||||
"jquery.cookie": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.cookie'
|
||||
},
|
||||
"jquery.tooltip": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.tooltip'
|
||||
},
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.ui.widget": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jfu.fileupload": {
|
||||
deps: ["jquery.ui.widget"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mocha.setup({
|
||||
ui: "bdd",
|
||||
ignoreLeaks: false,
|
||||
globals: ['ab']
|
||||
});
|
||||
|
||||
console = window.console || function () {};
|
||||
|
||||
window.notrack = true;
|
||||
|
||||
window.runMocha = function () {
|
||||
if (window.mochaPhantomJS) {
|
||||
mochaPhantomJS.run();
|
||||
} else {
|
||||
mocha.run();
|
||||
}
|
||||
};
|
||||
require([
|
||||
'tests/specs/validator'
|
||||
], window.runMocha);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
89
www/scripts/tests/websocket.html
Normal file
89
www/scripts/tests/websocket.html
Normal file
@@ -0,0 +1,89 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Mocha Spec Runner</title>
|
||||
<link rel="stylesheet" href="./../../../tmp-assets/mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="./../../../tmp-assets/mocha/mocha.js"></script>
|
||||
<script src="./../../../tmp-assets/sinonjs/sinon.js"></script>
|
||||
<script src="../../assets/requirejs/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
baseUrl: "../../scripts",
|
||||
paths: {
|
||||
"chai" : "../../tmp-assets/chai/chai",
|
||||
"fixtures": "../../tmp-assets/js-fixtures/fixtures",
|
||||
"jquery": "../assets/jquery/jquery",
|
||||
"backbone": "../assets/backbone-amd/backbone",
|
||||
"i18n": "../assets/i18next/i18next.amd-1.6.3",
|
||||
"bootstrap": "../assets/bootstrap/js/bootstrap.min",
|
||||
"sinonchai": "../../tmp-assets/sinon-chai/lib/sinon-chai",
|
||||
"squire": "../../tmp-assets/squire/src/Squire",
|
||||
"jquery.ui": "../assets/jquery.ui/jquery-ui",
|
||||
"underscore": "../assets/underscore-amd/underscore",
|
||||
"jquery.ui.widget": "../assets/jquery-file-upload/jquery.ui.widget",
|
||||
"jquery.cookie": "../assets/jquery.cookie/jquery.cookie",
|
||||
"jquery.treeview": "../assets/jquery.treeview/jquery.treeview",
|
||||
"jquery.tooltip": "../assets/jquery.tooltip/jquery.tooltip",
|
||||
"blueimp.loadimage" : "../assets/blueimp-load-image/load-image",
|
||||
"jfu.iframe-transport": "../assets/jquery-file-upload/jquery.iframe-transport",
|
||||
"jfu.fileupload": "../assets/jquery-file-upload/jquery.fileupload"
|
||||
},
|
||||
shim: {
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.treeview": {
|
||||
deps: ['jquery', 'jquery.cookie'],
|
||||
exports: '$.fn.treeview'
|
||||
},
|
||||
bootstrap:{
|
||||
deps: ['jquery']
|
||||
},
|
||||
"jquery.cookie": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.cookie'
|
||||
},
|
||||
"jquery.tooltip": {
|
||||
deps: ["jquery"],
|
||||
exports: '$.fn.tooltip'
|
||||
},
|
||||
"jquery.ui": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jquery.ui.widget": {
|
||||
deps: ["jquery"]
|
||||
},
|
||||
"jfu.fileupload": {
|
||||
deps: ["jquery.ui.widget"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mocha.setup({
|
||||
ui: "bdd",
|
||||
ignoreLeaks: false,
|
||||
globals: ['ab']
|
||||
});
|
||||
|
||||
console = window.console || function () {};
|
||||
|
||||
window.notrack = true;
|
||||
|
||||
window.runMocha = function () {
|
||||
if (window.mochaPhantomJS) {
|
||||
mochaPhantomJS.run();
|
||||
} else {
|
||||
mocha.run();
|
||||
}
|
||||
};
|
||||
require([
|
||||
'tests/specs/websockets/connection',
|
||||
'tests/specs/websockets/subscriberManager'
|
||||
], window.runMocha);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user