2018-01-16 06:58:15 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
2018-02-12 08:55:56 +01:00
|
|
|
Test various crap patterns found in Flectra code to ensure they don't blow up
|
2018-01-16 06:58:15 +01:00
|
|
|
the parser thingie
|
|
|
|
"""
|
|
|
|
from autojsdoc.parser import jsdoc
|
|
|
|
from support import parse
|
|
|
|
|
|
|
|
def test_export_external():
|
|
|
|
[mod] = parse("""
|
2018-02-12 08:55:56 +01:00
|
|
|
flectra.define('module', function () {
|
2018-01-16 06:58:15 +01:00
|
|
|
return $.Deferred().reject();
|
|
|
|
});
|
|
|
|
""")
|
|
|
|
assert isinstance(mod.exports, jsdoc.CommentDoc)
|
|
|
|
assert mod.exports.doc == ''
|
|
|
|
|
|
|
|
def test_extend_jq():
|
|
|
|
parse("""
|
2018-02-12 08:55:56 +01:00
|
|
|
flectra.define('a', function (r) {
|
2018-01-16 06:58:15 +01:00
|
|
|
$.extend($.expr[':'], { a: function () {} });
|
|
|
|
$.fn.extend({ a: function () {} });
|
|
|
|
});
|
|
|
|
""")
|
|
|
|
|
|
|
|
def test_extend_dynamic():
|
|
|
|
parse("""
|
2018-02-12 08:55:56 +01:00
|
|
|
flectra.define('a', function () {
|
2018-01-16 06:58:15 +01:00
|
|
|
foo.bar.baz[qux + '_external'] = function () {};
|
|
|
|
});
|
|
|
|
""")
|
|
|
|
|
|
|
|
def test_extend_deep():
|
|
|
|
parse("""
|
2018-02-12 08:55:56 +01:00
|
|
|
flectra.define('a', function () {
|
2018-01-16 06:58:15 +01:00
|
|
|
var eventHandler = $.summernote.eventHandler;
|
|
|
|
var dom = $.summernote.core.dom;
|
|
|
|
dom.thing = function () {};
|
|
|
|
|
|
|
|
var fn_editor_currentstyle = eventHandler.modules.editor.currentStyle;
|
|
|
|
eventHandler.modules.editor.currentStyle = function () {}
|
|
|
|
});
|
|
|
|
""")
|
|
|
|
|
|
|
|
def test_arbitrary():
|
|
|
|
parse("""
|
2018-02-12 08:55:56 +01:00
|
|
|
flectra.define('bob', function () {
|
2018-01-16 06:58:15 +01:00
|
|
|
var page = window.location.href.replace(/^.*\/\/[^\/]+/, '');
|
|
|
|
var mailWidgets = ['mail_followers', 'mail_thread', 'mail_activity', 'kanban_activity'];
|
|
|
|
var bob;
|
|
|
|
var fldj = foo.getTemplate().baz;
|
|
|
|
});
|
|
|
|
""")
|
|
|
|
|
|
|
|
def test_prototype():
|
|
|
|
[A, B] = parse("""
|
2018-02-12 08:55:56 +01:00
|
|
|
flectra.define('mod1', function () {
|
2018-01-16 06:58:15 +01:00
|
|
|
var exports = {};
|
|
|
|
exports.Foo = Backbone.Model.extend({});
|
|
|
|
exports.Bar = Backbone.Model.extend({});
|
|
|
|
var BarCollection = Backbone.Collection.extend({
|
|
|
|
model: exports.Bar,
|
|
|
|
});
|
|
|
|
exports.Baz = Backbone.Model.extend({});
|
|
|
|
return exports;
|
|
|
|
});
|
2018-02-12 08:55:56 +01:00
|
|
|
flectra.define('mod2', function (require) {
|
2018-01-16 06:58:15 +01:00
|
|
|
var models = require('mod1');
|
|
|
|
var _super_orderline = models.Bar.prototype;
|
|
|
|
models.Foo = models.Bar.extend({});
|
|
|
|
var _super_order = models.Baz.prototype;
|
|
|
|
models.Bar = models.Baz.extend({});
|
|
|
|
});
|
|
|
|
""")
|
|
|
|
|