Compare commits

...

1 Commits

Author SHA1 Message Date
Roberto Rosario
9340afd196 Initial commit to support QUnit tests
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
2019-09-26 00:28:44 -04:00
6 changed files with 70 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
'use strict';
QUnit.test('partialNavigation.filterLocation', function (assert) {
var testPartialNavigation = new PartialNavigation({
initialURL: '/testInitialURL',
});
/*
* For an empty newLocation we expect the fragment of the URL minus the
* query
*/
var expected = new URI(new URI(location).fragment()).path().toString();
assert.strictEqual(
testPartialNavigation.filterLocation(''), expected, 'newLocation === ""');
/*
* For an empty root value we expect initialURL passed to the
* partialNavigation instance when initialized.
*/
assert.strictEqual(
testPartialNavigation.filterLocation('/'), testPartialNavigation.initialURL, 'newLocation === "/"'
);
/*
* For an empty root value we expect initialURL passed to the
* partialNavigation instance when initialized.
*/
assert.strictEqual(
testPartialNavigation.filterLocation('random'), 'random', 'newLocation === "random"'
);
});

View File

@@ -38,6 +38,7 @@
<script src="{% static 'appearance/node_modules/jquery/dist/jquery.min.js' %}" type="text/javascript"></script>
<script src="{% static 'appearance/node_modules/bootstrap/dist/js/bootstrap.min.js' %}" type="text/javascript"></script>
<script src="{% static 'appearance/node_modules/@fortawesome/fontawesome-free/js/all.min.js' %}" data-auto-replace-svg="nest" type="text/javascript"></script>
{% block javascript %}{% endblock %}
</body>
</html>
{% endspaceless %}

View File

@@ -4,7 +4,12 @@ from django.utils.translation import ugettext_lazy as _
from mayan.apps.dependencies.classes import (
environment_build, environment_development, environment_testing,
PythonDependency
JavaScriptDependency, PythonDependency
)
JavaScriptDependency(
environment=environment_testing, label=_('QUnit'), module=__name__,
name='qunit', version_string='=2.9.2'
)
PythonDependency(

View File

@@ -0,0 +1,22 @@
{% extends 'appearance/base.html' %}
{% load i18n %}
{% load static %}
{% block base_title %}{% trans 'Qunit' %}{% endblock %}
{% block project_name %}{% endblock %}
{% block stylesheets %}
<link href="{% static 'common/node_modules/qunit/qunit/qunit.css' %}" media="screen" rel="stylesheet" type="text/css" />
{% endblock %}
{% block content %}
<div id="qunit"></div>
<div id="qunit-fixture"></div>
{% endblock %}
{% block javascript %}
<script src="{% static 'common/node_modules/qunit/qunit/qunit.js' %}" type="text/javascript"></script>
<script src="{% static 'appearance/js/test/unit/partial_navigation.js' %}" type="text/javascript"></script>
{% endblock %}

View File

@@ -10,7 +10,8 @@ from .views import (
AboutView, CurrentUserLocaleProfileDetailsView,
CurrentUserLocaleProfileEditView, FaviconRedirectView, HomeView,
LicenseView, ObjectErrorLogEntryListClearView, ObjectErrorLogEntryListView,
RootView, SetupListView, ToolsListView, multi_object_action_view
RootView, SetupListView, ToolsListView, QUnitView,
multi_object_action_view
)
urlpatterns = [
@@ -43,6 +44,9 @@ urlpatterns = [
view=ObjectErrorLogEntryListClearView.as_view(),
name='object_error_list_clear'
),
url(
regex=r'^qunit/', view=QUnitView.as_view(), name='qunit'
)
]
urlpatterns += [

View File

@@ -276,3 +276,8 @@ def multi_object_action_view(request):
action, urlencode({'id_list': id_list, 'next': next})
)
)
class QUnitView(SimpleView):
extra_context = {'title': _('QUnit tests')}
template_name = 'common/qunit.html'