[IMP] port basic/existing tests to new framework, apart from editor stuff

bzr revid: xmo@openerp.com-20121026092144-0arxx2v9oi28e3d6
This commit is contained in:
Xavier Morel 2012-10-26 11:21:44 +02:00
parent 04282ff00e
commit a130035409
9 changed files with 395 additions and 459 deletions

View File

@ -151,6 +151,9 @@ openerp.testing = {};
// TODO: clean up this mess
var d = opts.dependencies.slice();
// dependencies list should be in deps order, reverse to make
// loading order from last
d.reverse();
var di = 0;
while (di < d.length) {
var m = /^web\.(\w+)$/.exec(d[di]);

View File

@ -1,32 +1,7 @@
$(document).ready(function () {
var $fix = $('#qunit-fixture');
var mod = {
setup: function () {
instance = window.openerp.init([]);
window.openerp.web.corelib(instance);
instance.web.qweb = new QWeb2.Engine();
instance.web.qweb.add_template(
'<no>' +
'<t t-name="test.widget.template">' +
'<ol>' +
'<li t-foreach="5" t-as="counter" ' +
't-attf-class="class-#{counter}">' +
'<input/>' +
'<t t-esc="counter"/>' +
'</li>' +
'</ol>' +
'</t>' +
'<t t-name="test.widget.template-value">' +
'<p><t t-esc="widget.value"/></p>' +
'</t>' +
'</no>');
}
};
var instance;
module('Widget.proxy', mod);
test('(String)', function () {
openerp.testing.section('Widget.proxy', {
dependencies: ['web.corelib']
}, function (test) {
test('(String)', function (instance) {
var W = instance.web.Widget.extend({
exec: function () {
this.executed = true;
@ -37,7 +12,7 @@ $(document).ready(function () {
fn();
ok(w.executed, 'should execute the named method in the right context');
});
test('(String)(*args)', function () {
test('(String)(*args)', function (instance) {
var W = instance.web.Widget.extend({
exec: function (arg) {
this.executed = arg;
@ -49,7 +24,7 @@ $(document).ready(function () {
ok(w.executed, "should execute the named method in the right context");
equal(w.executed, 42, "should be passed the proxy's arguments");
});
test('(String), include', function () {
test('(String), include', function (instance) {
// the proxy function should handle methods being changed on the class
// and should always proxy "by name", to the most recent one
var W = instance.web.Widget.extend({
@ -67,23 +42,43 @@ $(document).ready(function () {
equal(w.executed, 2, "should be lazily resolved");
});
test('(Function)', function () {
test('(Function)', function (instance) {
var w = new (instance.web.Widget.extend({ }));
var fn = w.proxy(function () { this.executed = true; });
fn();
ok(w.executed, "should set the function's context (like Function#bind)");
});
test('(Function)(*args)', function () {
test('(Function)(*args)', function (instance) {
var w = new (instance.web.Widget.extend({ }));
var fn = w.proxy(function (arg) { this.executed = arg; });
fn(42);
equal(w.executed, 42, "should be passed the proxy's arguments");
});
module('Widget.renderElement', mod);
test('no template, default', function () {
});
openerp.testing.section('Widget.renderElement', {
dependencies: ['web.corelib'],
setup: function (instance) {
instance.web.qweb = new QWeb2.Engine();
instance.web.qweb.add_template(
'<no>' +
'<t t-name="test.widget.template">' +
'<ol>' +
'<li t-foreach="5" t-as="counter" ' +
't-attf-class="class-#{counter}">' +
'<input/>' +
'<t t-esc="counter"/>' +
'</li>' +
'</ol>' +
'</t>' +
'<t t-name="test.widget.template-value">' +
'<p><t t-esc="widget.value"/></p>' +
'</t>' +
'</no>');
}
}, function (test) {
test('no template, default', function (instance) {
var w = new (instance.web.Widget.extend({ }));
var $original = w.$el;
@ -98,7 +93,7 @@ $(document).ready(function () {
equal(w.el.attributes.length, 0, "should not have generated any attribute");
ok(_.isEmpty(w.$el.html(), "should not have generated any content"));
});
test('no template, custom tag', function () {
test('no template, custom tag', function (instance) {
var w = new (instance.web.Widget.extend({
tagName: 'ul'
}));
@ -106,7 +101,7 @@ $(document).ready(function () {
equal(w.el.nodeName, 'UL', "should have generated the custom element tag");
});
test('no template, @id', function () {
test('no template, @id', function (instance) {
var w = new (instance.web.Widget.extend({
id: 'foo'
}));
@ -116,7 +111,7 @@ $(document).ready(function () {
equal(w.$el.attr('id'), 'foo', "should have generated the id attribute");
equal(w.el.id, 'foo', "should also be available via property");
});
test('no template, @className', function () {
test('no template, @className', function (instance) {
var w = new (instance.web.Widget.extend({
className: 'oe_some_class'
}));
@ -125,7 +120,7 @@ $(document).ready(function () {
equal(w.el.className, 'oe_some_class', "should have the right property");
equal(w.$el.attr('class'), 'oe_some_class', "should have the right attribute");
});
test('no template, bunch of attributes', function () {
test('no template, bunch of attributes', function (instance) {
var w = new (instance.web.Widget.extend({
attributes: {
'id': 'some_id',
@ -152,7 +147,7 @@ $(document).ready(function () {
equal(w.$el.attr('spoiler'), 'snape kills dumbledore');
});
test('template', function () {
test('template', function (instance) {
var w = new (instance.web.Widget.extend({
template: 'test.widget.template'
}));
@ -162,9 +157,41 @@ $(document).ready(function () {
equal(w.$el.children().length, 5);
equal(w.el.textContent, '01234');
});
module('Widget.$', mod);
test('basic-alias', function () {
test('repeated', { asserts: 4 }, function (instance, $fix) {
var w = new (instance.web.Widget.extend({
template: 'test.widget.template-value'
}));
w.value = 42;
return w.appendTo($fix)
.done(function () {
equal($fix.find('p').text(), '42', "DOM fixture should contain initial value");
equal(w.$el.text(), '42', "should set initial value");
w.value = 36;
w.renderElement();
equal($fix.find('p').text(), '36', "DOM fixture should use new value");
equal(w.$el.text(), '36', "should set new value");
});
});
});
openerp.testing.section('Widget.$', {
dependencies: ['web.corelib'],
setup: function (instance) {
instance.web.qweb = new QWeb2.Engine();
instance.web.qweb.add_template(
'<no>' +
'<t t-name="test.widget.template">' +
'<ol>' +
'<li t-foreach="5" t-as="counter" ' +
't-attf-class="class-#{counter}">' +
'<input/>' +
'<t t-esc="counter"/>' +
'</li>' +
'</ol>' +
'</t>' +
'</no>');
}
}, function (test) {
test('basic-alias', function (instance) {
var w = new (instance.web.Widget.extend({
template: 'test.widget.template'
}));
@ -173,9 +200,26 @@ $(document).ready(function () {
ok(w.$('li:eq(3)').is(w.$el.find('li:eq(3)')),
"should do the same thing as calling find on the widget root");
});
module('Widget.events', mod);
test('delegate', function () {
});
openerp.testing.section('Widget.events', {
dependencies: ['web.corelib'],
setup: function (instance) {
instance.web.qweb = new QWeb2.Engine();
instance.web.qweb.add_template(
'<no>' +
'<t t-name="test.widget.template">' +
'<ol>' +
'<li t-foreach="5" t-as="counter" ' +
't-attf-class="class-#{counter}">' +
'<input/>' +
'<t t-esc="counter"/>' +
'</li>' +
'</ol>' +
'</t>' +
'</no>');
}
}, function (test) {
test('delegate', function (instance) {
var a = [];
var w = new (instance.web.Widget.extend({
template: 'test.widget.template',
@ -199,7 +243,7 @@ $(document).ready(function () {
ok(a[i], "should pass test " + i);
}
});
test('undelegate', function () {
test('undelegate', function (instance) {
var clicked = false, newclicked = false;
var w = new (instance.web.Widget.extend({
template: 'test.widget.template',
@ -218,22 +262,4 @@ $(document).ready(function () {
ok(!clicked, "undelegate should unbind events delegated");
ok(newclicked, "undelegate should only unbind events it created");
});
module('Widget.renderElement', mod);
asyncTest('repeated', 4, function () {
var w = new (instance.web.Widget.extend({
template: 'test.widget.template-value'
}));
w.value = 42;
w.appendTo($fix)
.always(start)
.done(function () {
equal($fix.find('p').text(), '42', "DOM fixture should contain initial value");
equal(w.$el.text(), '42', "should set initial value");
w.value = 36;
w.renderElement();
equal($fix.find('p').text(), '36', "DOM fixture should use new value");
equal(w.$el.text(), '36', "should set new value");
});
});
});

View File

@ -1,30 +1,25 @@
$(document).ready(function () {
var openerp;
module('web-class', {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
}
});
test('Basic class creation', function () {
var C = openerp.web.Class.extend({
openerp.testing.section('class', {
dependencies: ['web.corelib']
}, function (test) {
test('Basic class creation', function (instance) {
var C = instance.web.Class.extend({
foo: function () {
return this.somevar;
}
});
var instance = new C();
instance.somevar = 3;
var i = new C();
i.somevar = 3;
ok(instance instanceof C);
strictEqual(instance.foo(), 3);
ok(i instanceof C);
strictEqual(i.foo(), 3);
});
test('Class initialization', function () {
var C1 = openerp.web.Class.extend({
test('Class initialization', function (instance) {
var C1 = instance.web.Class.extend({
init: function () {
this.foo = 3;
}
});
var C2 = openerp.web.Class.extend({
var C2 = instance.web.Class.extend({
init: function (arg) {
this.foo = arg;
}
@ -36,8 +31,8 @@ $(document).ready(function () {
strictEqual(i1.foo, 3);
strictEqual(i2.foo, 42);
});
test('Inheritance', function () {
var C0 = openerp.web.Class.extend({
test('Inheritance', function (instance) {
var C0 = instance.web.Class.extend({
foo: function () {
return 1;
}
@ -57,8 +52,8 @@ $(document).ready(function () {
strictEqual(new C1().foo(), 2);
strictEqual(new C2().foo(), 3);
});
test('In-place extension', function () {
var C0 = openerp.web.Class.extend({
test('In-place extension', function (instance) {
var C0 = instance.web.Class.extend({
foo: function () {
return 3;
},
@ -83,8 +78,8 @@ $(document).ready(function () {
strictEqual(new C0().foo(), 5);
strictEqual(new C0().qux(), 5);
});
test('In-place extension and inheritance', function () {
var C0 = openerp.web.Class.extend({
test('In-place extension and inheritance', function (instance) {
var C0 = instance.web.Class.extend({
foo: function () { return 1; },
bar: function () { return 1; }
});
@ -101,24 +96,24 @@ $(document).ready(function () {
strictEqual(new C1().foo(), 4);
strictEqual(new C1().bar(), 2);
});
test('In-place extensions alter existing instances', function () {
var C0 = openerp.web.Class.extend({
test('In-place extensions alter existing instances', function (instance) {
var C0 = instance.web.Class.extend({
foo: function () { return 1; },
bar: function () { return 1; }
});
var instance = new C0();
strictEqual(instance.foo(), 1);
strictEqual(instance.bar(), 1);
var i = new C0();
strictEqual(i.foo(), 1);
strictEqual(i.bar(), 1);
C0.include({
foo: function () { return 2; },
bar: function () { return 2 + this._super(); }
});
strictEqual(instance.foo(), 2);
strictEqual(instance.bar(), 3);
strictEqual(i.foo(), 2);
strictEqual(i.bar(), 3);
});
test('In-place extension of subclassed types', function () {
var C0 = openerp.web.Class.extend({
test('In-place extension of subclassed types', function (instance) {
var C0 = instance.web.Class.extend({
foo: function () { return 1; },
bar: function () { return 1; }
});
@ -126,13 +121,13 @@ $(document).ready(function () {
foo: function () { return 1 + this._super(); },
bar: function () { return 1 + this._super(); }
});
var instance = new C1();
strictEqual(instance.foo(), 2);
var i = new C1();
strictEqual(i.foo(), 2);
C0.include({
foo: function () { return 2; },
bar: function () { return 2 + this._super(); }
});
strictEqual(instance.foo(), 3);
strictEqual(instance.bar(), 4);
strictEqual(i.foo(), 3);
strictEqual(i.bar(), 4);
});
});

View File

@ -1,18 +1,11 @@
$(document).ready(function () {
var openerp;
module("eval.contexts", {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
}
});
test('context_sequences', function () {
openerp.testing.section('eval.contexts', {
dependencies: ['web.coresetup']
}, function (test) {
test('context_sequences', function (instance) {
// Context n should have base evaluation context + all of contexts
// 0..n-1 in its own evaluation context
var active_id = 4;
var result = openerp.session.test_eval_contexts([
var result = instance.session.test_eval_contexts([
{
"__contexts": [
{
@ -55,8 +48,8 @@ $(document).ready(function () {
record_id: active_id
});
});
test('non-literal_eval_contexts', function () {
var result = openerp.session.test_eval_contexts([{
test('non-literal_eval_contexts', function (instance) {
var result = instance.session.test_eval_contexts([{
"__ref": "compound_context",
"__contexts": [
{"__ref": "context", "__debug": "{'type':parent.type}",
@ -133,17 +126,15 @@ $(document).ready(function () {
}]);
deepEqual(result, {type: 'out_invoice'});
});
module('eval.domains', {
setup: function () {
openerp = window.openerp.testing.instanceFor('coresetup');
window.openerp.web.dates(openerp);
}
});
test('current_date', function () {
var current_date = openerp.web.date_to_str(new Date());
var result = openerp.session.test_eval_domains(
});
openerp.testing.section('eval.contexts', {
dependencies: ['web.coresetup', 'web.dates']
}, function (test) {
test('current_date', function (instance) {
var current_date = instance.web.date_to_str(new Date());
var result = instance.session.test_eval_domains(
[[],{"__ref":"domain","__debug":"[('name','>=',current_date),('name','<=',current_date)]","__id":"5dedcfc96648"}],
openerp.session.test_eval_get_context());
instance.session.test_eval_get_context());
deepEqual(result, [
['name', '>=', current_date],
['name', '<=', current_date]

View File

@ -1,33 +1,21 @@
$(document).ready(function () {
var openerp;
module("form.widget", {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
window.openerp.web.chrome(openerp);
// views loader stuff
window.openerp.web.data(openerp);
window.openerp.web.views(openerp);
window.openerp.web.list(openerp);
window.openerp.web.form(openerp);
}
});
test("compute_domain", function () {
openerp.testing.section('compute_domain', {
dependencies: ['web.form']
}, function (test) {
test("basic", function (instance) {
var fields = {
'a': {value: 3},
'group_method': {value: 'line'},
'select1': {value: 'day'},
'rrule_type': {value: 'monthly'}
};
ok(openerp.web.form.compute_domain(
ok(instance.web.form.compute_domain(
[['a', '=', 3]], fields));
ok(openerp.web.form.compute_domain(
ok(instance.web.form.compute_domain(
[['group_method','!=','count']], fields));
ok(openerp.web.form.compute_domain(
ok(instance.web.form.compute_domain(
[['select1','=','day'], ['rrule_type','=','monthly']], fields));
});
test("compute_domain or", function () {
test("or", function (instance) {
var web = {
'section_id': {value: null},
'user_id': {value: null},
@ -38,22 +26,22 @@ $(document).ready(function () {
'|', ['user_id','=',3],
['member_ids', 'in', [3]]];
ok(openerp.web.form.compute_domain(domain, _.extend(
ok(instance.web.form.compute_domain(domain, _.extend(
{}, web, {'section_id': {value: 42}})));
ok(openerp.web.form.compute_domain(domain, _.extend(
ok(instance.web.form.compute_domain(domain, _.extend(
{}, web, {'user_id': {value: 3}})));
ok(openerp.web.form.compute_domain(domain, _.extend(
ok(instance.web.form.compute_domain(domain, _.extend(
{}, web, {'member_ids': {value: 3}})));
});
test("compute_domain not", function () {
test("not", function (instance) {
var fields = {
'a': {value: 5},
'group_method': {value: 'line'}
};
ok(openerp.web.form.compute_domain(
ok(instance.web.form.compute_domain(
['!', ['a', '=', 3]], fields));
ok(openerp.web.form.compute_domain(
ok(instance.web.form.compute_domain(
['!', ['group_method','=','count']], fields));
});
});

View File

@ -1,16 +1,8 @@
$(document).ready(function () {
var openerp;
module('server-formats', {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
window.openerp.web.dates(openerp);
}
});
test('Parse server datetime', function () {
var date = openerp.web.str_to_datetime("2009-05-04 12:34:23");
openerp.testing.section('server-formats', {
dependencies: ['web.coresetup', 'web.dates']
}, function (test) {
test('Parse server datetime', function (instance) {
var date = instance.web.str_to_datetime("2009-05-04 12:34:23");
deepEqual(
[date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(),
date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()],
@ -20,92 +12,86 @@ $(document).ready(function () {
date.getHours(), date.getMinutes(), date.getSeconds()],
[2009, 5 - 1, 4, 12 - (date.getTimezoneOffset() / 60), 34, 23]);
var date2 = openerp.web.str_to_datetime('2011-12-10 00:00:00');
var date2 = instance.web.str_to_datetime('2011-12-10 00:00:00');
deepEqual(
[date2.getUTCFullYear(), date2.getUTCMonth(), date2.getUTCDate(),
date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds()],
[2011, 12 - 1, 10, 0, 0, 0]);
});
test('Parse server date', function () {
var date = openerp.web.str_to_date("2009-05-04");
test('Parse server date', function (instance) {
var date = instance.web.str_to_date("2009-05-04");
deepEqual(
[date.getFullYear(), date.getMonth(), date.getDate()],
[2009, 5 - 1, 4]);
});
test('Parse server time', function () {
var date = openerp.web.str_to_time("12:34:23");
test('Parse server time', function (instance) {
var date = instance.web.str_to_time("12:34:23");
deepEqual(
[date.getHours(), date.getMinutes(), date.getSeconds()],
[12, 34, 23]);
});
module('web-formats', {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
window.openerp.web.dates(openerp);
window.openerp.web.formats(openerp);
}
});
test("format_datetime", function () {
var date = openerp.web.str_to_datetime("2009-05-04 12:34:23");
var str = openerp.web.format_value(date, {type:"datetime"});
});
openerp.testing.section('web-formats', {
dependencies: ['web.formats']
}, function (test) {
test("format_datetime", function (instance) {
var date = instance.web.str_to_datetime("2009-05-04 12:34:23");
var str = instance.web.format_value(date, {type:"datetime"});
equal(str, date.toString("MM/dd/yyyy HH:mm:ss"));
});
test("format_date", function () {
var date = openerp.web.str_to_datetime("2009-05-04 12:34:23");
var str = openerp.web.format_value(date, {type:"date"});
test("format_date", function (instance) {
var date = instance.web.str_to_datetime("2009-05-04 12:34:23");
var str = instance.web.format_value(date, {type:"date"});
equal(str, date.toString("MM/dd/yyyy"));
});
test("format_time", function () {
var date = openerp.web.str_to_datetime("2009-05-04 12:34:23");
var str = openerp.web.format_value(date, {type:"time"});
test("format_time", function (instance) {
var date = instance.web.str_to_datetime("2009-05-04 12:34:23");
var str = instance.web.format_value(date, {type:"time"});
equal(str, date.toString("HH:mm:ss"));
});
test("format_float_time", function () {
test("format_float_time", function (instance) {
strictEqual(
openerp.web.format_value(1.0, {type:'float', widget:'float_time'}),
instance.web.format_value(1.0, {type:'float', widget:'float_time'}),
'01:00');
strictEqual(
openerp.web.format_value(0.9853, {type:'float', widget:'float_time'}),
instance.web.format_value(0.9853, {type:'float', widget:'float_time'}),
'00:59');
strictEqual(
openerp.web.format_value(0.0085, {type:'float', widget:'float_time'}),
instance.web.format_value(0.0085, {type:'float', widget:'float_time'}),
'00:01');
strictEqual(
openerp.web.format_value(-1.0, {type:'float', widget:'float_time'}),
instance.web.format_value(-1.0, {type:'float', widget:'float_time'}),
'-01:00');
strictEqual(
openerp.web.format_value(-0.9853, {type:'float', widget:'float_time'}),
instance.web.format_value(-0.9853, {type:'float', widget:'float_time'}),
'-00:59');
strictEqual(
openerp.web.format_value(-0.0085, {type:'float', widget:'float_time'}),
instance.web.format_value(-0.0085, {type:'float', widget:'float_time'}),
'-00:01');
});
test("format_float", function () {
test("format_float", function (instance) {
var fl = 12.1234;
var str = openerp.web.format_value(fl, {type:"float"});
var str = instance.web.format_value(fl, {type:"float"});
equal(str, "12.12");
equal(openerp.web.format_value(12.02, {type: 'float'}),
equal(instance.web.format_value(12.02, {type: 'float'}),
'12.02');
equal(openerp.web.format_value(0.0002, {type: 'float', digits: [1, 3]}),
equal(instance.web.format_value(0.0002, {type: 'float', digits: [1, 3]}),
'0.000');
equal(openerp.web.format_value(0.0002, {type: 'float', digits: [1, 4]}),
equal(instance.web.format_value(0.0002, {type: 'float', digits: [1, 4]}),
'0.0002');
equal(openerp.web.format_value(0.0002, {type: 'float', digits: [1, 6]}),
equal(instance.web.format_value(0.0002, {type: 'float', digits: [1, 6]}),
'0.000200');
equal(openerp.web.format_value(1, {type: 'float', digits: [1, 6]}),
equal(instance.web.format_value(1, {type: 'float', digits: [1, 6]}),
'1.000000');
equal(openerp.web.format_value(1, {type: 'float'}),
equal(instance.web.format_value(1, {type: 'float'}),
'1.00');
equal(openerp.web.format_value(-11.25, {type: 'float'}),
equal(instance.web.format_value(-11.25, {type: 'float'}),
"-11.25");
openerp.web._t.database.parameters.grouping = [1, 2, -1];
equal(openerp.web.format_value(1111111.25, {type: 'float'}),
instance.web._t.database.parameters.grouping = [1, 2, -1];
equal(instance.web.format_value(1111111.25, {type: 'float'}),
"1111,11,1.25");
openerp.web._t.database.parameters.grouping = [1, 0];
equal(openerp.web.format_value(-11.25, {type: 'float'}),
instance.web._t.database.parameters.grouping = [1, 0];
equal(instance.web.format_value(-11.25, {type: 'float'}),
"-1,1.25");
});
// test("parse_datetime", function () {
@ -123,29 +109,29 @@ $(document).ready(function () {
// var res = openerp.web.parse_value(val.toString("HH:mm:ss"), {type:"time"});
// equal(val.toString("HH:mm:ss"), res.toString("HH:mm:ss"));
// });
test('parse_integer', function () {
var val = openerp.web.parse_value('123,456', {type: 'integer'});
test('parse_integer', function (instance) {
var val = instance.web.parse_value('123,456', {type: 'integer'});
equal(val, 123456);
openerp.web._t.database.parameters.thousands_sep = '|';
var val2 = openerp.web.parse_value('123|456', {type: 'integer'});
instance.web._t.database.parameters.thousands_sep = '|';
var val2 = instance.web.parse_value('123|456', {type: 'integer'});
equal(val2, 123456);
});
test("parse_float", function () {
test("parse_float", function (instance) {
var str = "134,112.1234";
var val = openerp.web.parse_value(str, {type:"float"});
var val = instance.web.parse_value(str, {type:"float"});
equal(val, 134112.1234);
var str = "-134,112.1234";
var val = openerp.web.parse_value(str, {type:"float"});
var val = instance.web.parse_value(str, {type:"float"});
equal(val, -134112.1234);
_.extend(openerp.web._t.database.parameters, {
_.extend(instance.web._t.database.parameters, {
decimal_point: ',',
thousands_sep: '.'
});
var val3 = openerp.web.parse_value('123.456,789', {type: 'float'});
var val3 = instance.web.parse_value('123.456,789', {type: 'float'});
equal(val3, 123456.789);
});
test('intersperse', function () {
var g = openerp.web.intersperse;
test('intersperse', function (instance) {
var g = instance.web.intersperse;
equal(g("", []), "");
equal(g("0", []), "0");
equal(g("012", []), "012");
@ -176,60 +162,61 @@ $(document).ready(function () {
equal(g("12345678", [3,3,3,3], '.'), '12.345.678');
equal(g("12345678", [3,0], '.'), '12.345.678');
});
test('format_integer', function () {
openerp.web._t.database.parameters.grouping = [3, 3, 3, 3];
equal(openerp.web.format_value(1000000, {type: 'integer'}),
test('format_integer', function (instance) {
instance.web._t.database.parameters.grouping = [3, 3, 3, 3];
equal(instance.web.format_value(1000000, {type: 'integer'}),
'1,000,000');
openerp.web._t.database.parameters.grouping = [3, 2, -1];
equal(openerp.web.format_value(106500, {type: 'integer'}),
instance.web._t.database.parameters.grouping = [3, 2, -1];
equal(instance.web.format_value(106500, {type: 'integer'}),
'1,06,500');
openerp.web._t.database.parameters.grouping = [1, 2, -1];
equal(openerp.web.format_value(106500, {type: 'integer'}),
instance.web._t.database.parameters.grouping = [1, 2, -1];
equal(instance.web.format_value(106500, {type: 'integer'}),
'106,50,0');
});
test('format_float', function () {
openerp.web._t.database.parameters.grouping = [3, 3, 3, 3];
equal(openerp.web.format_value(1000000, {type: 'float'}),
test('format_float', function (instance) {
instance.web._t.database.parameters.grouping = [3, 3, 3, 3];
equal(instance.web.format_value(1000000, {type: 'float'}),
'1,000,000.00');
openerp.web._t.database.parameters.grouping = [3, 2, -1];
equal(openerp.web.format_value(106500, {type: 'float'}),
instance.web._t.database.parameters.grouping = [3, 2, -1];
equal(instance.web.format_value(106500, {type: 'float'}),
'1,06,500.00');
openerp.web._t.database.parameters.grouping = [1, 2, -1];
equal(openerp.web.format_value(106500, {type: 'float'}),
instance.web._t.database.parameters.grouping = [1, 2, -1];
equal(instance.web.format_value(106500, {type: 'float'}),
'106,50,0.00');
_.extend(openerp.web._t.database.parameters, {
_.extend(instance.web._t.database.parameters, {
grouping: [3, 0],
decimal_point: ',',
thousands_sep: '.'
});
equal(openerp.web.format_value(6000, {type: 'float'}),
equal(instance.web.format_value(6000, {type: 'float'}),
'6.000,00');
});
module('custom-date-formats', {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
window.openerp.web.dates(openerp);
window.openerp.web.formats(openerp);
}
});
openerp.testing.section('web-formats', {
dependencies: ['web.formats']
}, function (test) {
test('format stripper', function (instance) {
strictEqual(instance.web.strip_raw_chars('%a, %Y %b %d'),
'%a, %Y %b %d');
strictEqual(instance.web.strip_raw_chars('%a, %Y.eko %bren %da'),
'%a, %Y. %b %d');
});
test('format stripper', function () {
strictEqual(openerp.web.strip_raw_chars('%a, %Y %b %d'), '%a, %Y %b %d');
strictEqual(openerp.web.strip_raw_chars('%a, %Y.eko %bren %da'), '%a, %Y. %b %d');
test('ES date format', function (instance) {
instance.web._t.database.parameters.date_format = '%a, %Y %b %d';
var date = instance.web.str_to_date("2009-05-04");
strictEqual(instance.web.format_value(date, {type:"date"}),
'Mon, 2009 May 04');
strictEqual(instance.web.parse_value('Mon, 2009 May 04', {type: 'date'}),
'2009-05-04');
});
test('ES date format', function () {
openerp.web._t.database.parameters.date_format = '%a, %Y %b %d';
var date = openerp.web.str_to_date("2009-05-04");
strictEqual(openerp.web.format_value(date, {type:"date"}), 'Mon, 2009 May 04');
strictEqual(openerp.web.parse_value('Mon, 2009 May 04', {type: 'date'}), '2009-05-04');
});
test('extended ES date format', function () {
openerp.web._t.database.parameters.date_format = '%a, %Y.eko %bren %da';
var date = openerp.web.str_to_date("2009-05-04");
strictEqual(openerp.web.format_value(date, {type:"date"}), 'Mon, 2009. May 04');
strictEqual(openerp.web.parse_value('Mon, 2009. May 04', {type: 'date'}), '2009-05-04');
test('extended ES date format', function (instance) {
instance.web._t.database.parameters.date_format = '%a, %Y.eko %bren %da';
var date = instance.web.str_to_date("2009-05-04");
strictEqual(instance.web.format_value(date, {type:"date"}),
'Mon, 2009. May 04');
strictEqual(instance.web.parse_value('Mon, 2009. May 04', {type: 'date'}),
'2009-05-04');
});
});

View File

@ -1,45 +1,34 @@
$(document).ready(function () {
var openerp,
create = function (o) {
if (typeof Object.create === 'function') {
return Object.create(o);
}
function Cls() {}
Cls.prototype = o;
return new Cls;
};
module('list-events', {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
window.openerp.web.chrome(openerp);
// views loader stuff
window.openerp.web.data(openerp);
window.openerp.web.views(openerp);
window.openerp.web.list(openerp);
openerp.testing.section('list.events', {
dependencies: ['web.list']
}, function (test) {
var create = function (o) {
if (typeof Object.create === 'function') {
return Object.create(o);
}
});
test('Simple event triggering', function () {
var e = create(openerp.web.list.Events), passed = false;
function Cls() {}
Cls.prototype = o;
return new Cls;
};
test('Simple event triggering', function (instance) {
var e = create(instance.web.list.Events), passed = false;
e.bind('foo', function () { passed = true; });
e.trigger('foo');
ok(passed);
});
test('Bind all', function () {
var e = create(openerp.web.list.Events), event = null;
test('Bind all', function (instance) {
var e = create(instance.web.list.Events), event = null;
e.bind(null, function (ev) { event = ev; });
e.trigger('foo');
strictEqual(event, 'foo');
});
test('Propagate trigger params', function () {
var e = create(openerp.web.list.Events), p = false;
test('Propagate trigger params', function (instance) {
var e = create(instance.web.list.Events), p = false;
e.bind(null, function (_, param) { p = param });
e.trigger('foo', true);
strictEqual(p, true)
});
test('Bind multiple callbacks', function () {
var e = create(openerp.web.list.Events), count;
test('Bind multiple callbacks', function (instance) {
var e = create(instance.web.list.Events), count;
e.bind('foo', function () { count++; })
.bind('bar', function () { count++; })
.bind(null, function () { count++; })
@ -59,20 +48,20 @@ $(document).ready(function () {
e.trigger('baz');
strictEqual(count, 3);
});
test('Mixin events', function () {
var cls = openerp.web.Class.extend({
test('Mixin events', function (instance) {
var cls = instance.web.Class.extend({
method: function () { this.trigger('e'); }
});
cls.include(openerp.web.list.Events);
var instance = new cls, triggered = false;
cls.include(instance.web.list.Events);
var i = new cls, triggered = false;
instance.bind('e', function () { triggered = true; });
instance.method();
i.bind('e', function () { triggered = true; });
i.method();
ok(triggered);
});
test('Unbind all handlers', function () {
var e = create(openerp.web.list.Events), passed = 0;
test('Unbind all handlers', function (instance) {
var e = create(instance.web.list.Events), passed = 0;
e.bind('foo', function () { passed++; });
e.trigger('foo');
strictEqual(passed, 1);
@ -80,8 +69,8 @@ $(document).ready(function () {
e.trigger('foo');
strictEqual(passed, 1);
});
test('Unbind one handler', function () {
var e = create(openerp.web.list.Events), p1 = 0, p2 = 0,
test('Unbind one handler', function (instance) {
var e = create(instance.web.list.Events), p1 = 0, p2 = 0,
h1 = function () { p1++; }, h2 = function () { p2++; };
e.bind('foo', h1);
e.bind('foo', h2);
@ -93,29 +82,20 @@ $(document).ready(function () {
strictEqual(p1, 1);
strictEqual(p2, 2);
});
module('list-records', {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
window.openerp.web.chrome(openerp);
// views loader stuff
window.openerp.web.data(openerp);
window.openerp.web.views(openerp);
window.openerp.web.list(openerp);
}
});
test('Basic record initialization', function () {
var r = new openerp.web.list.Record({qux: 3});
});
openerp.testing.section('list.records', {
dependencies: ['web.list']
}, function (test) {
test('Basic record initialization', function (instance) {
var r = new instance.web.list.Record({qux: 3});
r.set('foo', 1);
r.set('bar', 2);
strictEqual(r.get('foo'), 1);
strictEqual(r.get('bar'), 2);
strictEqual(r.get('qux'), 3);
});
test('Change all the things', function () {
var r = new openerp.web.list.Record(), changed = false, field;
test('Change all the things', function (instance) {
var r = new instance.web.list.Record(), changed = false, field;
r.bind('change', function () { changed = true; });
r.bind(null, function (e) { field = field || e.split(':')[1]});
r.set('foo', 1);
@ -123,8 +103,8 @@ $(document).ready(function () {
ok(changed);
strictEqual(field, 'foo');
});
test('Change single field', function () {
var r = new openerp.web.list.Record(), changed = 0;
test('Change single field', function (instance) {
var r = new instance.web.list.Record(), changed = 0;
r.bind('change:foo', function () { changed++; });
r.set('foo', 1);
r.set('bar', 1);
@ -132,21 +112,12 @@ $(document).ready(function () {
strictEqual(r.get('bar'), 1);
strictEqual(changed, 1);
});
module('list-collections', {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
window.openerp.web.chrome(openerp);
// views loader stuff
window.openerp.web.data(openerp);
window.openerp.web.views(openerp);
window.openerp.web.list(openerp);
}
});
test('degenerate-fetch', function () {
var c = new openerp.web.list.Collection();
});
openerp.testing.section('list.collections', {
dependencies: ['web.list']
}, function (test) {
test('degenerate-fetch', function (instance) {
var c = new instance.web.list.Collection();
strictEqual(c.length, 0);
c.add({id: 1, value: 2});
c.add({id: 2, value: 3});
@ -155,16 +126,16 @@ $(document).ready(function () {
strictEqual(c.length, 4);
var r = c.at(2), r2 = c.get(1);
ok(r instanceof openerp.web.list.Record);
ok(r instanceof instance.web.list.Record);
strictEqual(r.get('id'), 3);
strictEqual(r.get('value'), 5);
ok(r2 instanceof openerp.web.list.Record);
ok(r2 instanceof instance.web.list.Record);
strictEqual(r2.get('id'), 1);
strictEqual(r2.get('value'), 2);
});
test('degenerate-indexed-add', function () {
var c = new openerp.web.list.Collection([
test('degenerate-indexed-add', function (instance) {
var c = new instance.web.list.Collection([
{id: 1, value: 5},
{id: 2, value: 10},
{id: 3, value: 20}
@ -175,8 +146,8 @@ $(document).ready(function () {
strictEqual(c.at(1).get('value'), 55);
strictEqual(c.at(3).get('value'), 20);
});
test('degenerate-remove', function () {
var c = new openerp.web.list.Collection([
test('degenerate-remove', function (instance) {
var c = new instance.web.list.Collection([
{id: 1, value: 5},
{id: 2, value: 10},
{id: 3, value: 20}
@ -188,9 +159,9 @@ $(document).ready(function () {
equal(c.get(2), undefined);
strictEqual(c.at(1).get('value'), 20);
});
test('degenerate-remove-bound', function () {
test('degenerate-remove-bound', function (instance) {
var changed = false,
c = new openerp.web.list.Collection([ {id: 1, value: 5} ]);
c = new instance.web.list.Collection([ {id: 1, value: 5} ]);
c.bind('change', function () { changed = true; });
var record = c.get(1);
c.remove(record);
@ -198,8 +169,8 @@ $(document).ready(function () {
ok(!changed, 'removed records should not trigger events in their ' +
'parent collection');
});
test('degenerate-reset', function () {
var event, obj, c = new openerp.web.list.Collection([
test('degenerate-reset', function (instance) {
var event, obj, c = new instance.web.list.Collection([
{id: 1, value: 5},
{id: 2, value: 10},
{id: 3, value: 20}
@ -218,9 +189,9 @@ $(document).ready(function () {
strictEqual(c.length, 1);
strictEqual(c.get(42).get('value'), 55);
});
test('degenerate-reset-bound', function () {
test('degenerate-reset-bound', function (instance) {
var changed = false,
c = new openerp.web.list.Collection([ {id: 1, value: 5} ]);
c = new instance.web.list.Collection([ {id: 1, value: 5} ]);
c.bind('change', function () { changed = true; });
var record = c.get(1);
c.reset();
@ -229,9 +200,9 @@ $(document).ready(function () {
'parent collection');
});
test('degenerate-propagations', function () {
test('degenerate-propagations', function (instance) {
var values = [];
var c = new openerp.web.list.Collection([
var c = new instance.web.list.Collection([
{id: 1, value: 5},
{id: 2, value: 10},
{id: 3, value: 20}
@ -244,8 +215,8 @@ $(document).ready(function () {
c.get(3).set('value', 21);
deepEqual(values, [6, 11, 21]);
});
test('BTree', function () {
var root = new openerp.web.list.Collection(),
test('BTree', function (instance) {
var root = new instance.web.list.Collection(),
c = root.proxy('admin'),
total = 0;
c.add({id: 1, name: "Administrator", login: 'admin'});
@ -260,8 +231,8 @@ $(document).ready(function () {
c.at(1).set('wealth', 5);
strictEqual(total, 47);
});
test('degenerate-successor', function () {
var root = new openerp.web.list.Collection([
test('degenerate-successor', function (instance) {
var root = new instance.web.list.Collection([
{id: 1, value: 1},
{id: 2, value: 2},
{id: 3, value: 3},
@ -282,8 +253,8 @@ $(document).ready(function () {
root.at(3).attributes,
"wraparound should have no effect if not succ(last_record)");
});
test('successor', function () {
var root = new openerp.web.list.Collection();
test('successor', function (instance) {
var root = new instance.web.list.Collection();
root.proxy('first').add([{id: 1, value: 1}, {id: 2, value: 2}]);
root.proxy('second').add([{id: 3, value: 3}, {id: 4, value: 5}]);
root.proxy('third').add([{id: 5, value: 8}, {id: 6, value: 13}]);
@ -298,8 +269,8 @@ $(document).ready(function () {
root.get(3).attributes,
"should wraparound within a collection");
});
test('degenerate-predecessor', function () {
var root = new openerp.web.list.Collection([
test('degenerate-predecessor', function (instance) {
var root = new instance.web.list.Collection([
{id: 1, value: 1},
{id: 2, value: 2},
{id: 3, value: 3},
@ -320,8 +291,8 @@ $(document).ready(function () {
root.at(0).attributes,
"wraparound should have no effect if not pred(first_record)");
});
test('predecessor', function () {
var root = new openerp.web.list.Collection();
test('predecessor', function (instance) {
var root = new instance.web.list.Collection();
root.proxy('first').add([{id: 1, value: 1}, {id: 2, value: 2}]);
root.proxy('second').add([{id: 3, value: 3}, {id: 4, value: 5}]);
root.proxy('third').add([{id: 5, value: 8}, {id: 6, value: 13}]);
@ -336,21 +307,12 @@ $(document).ready(function () {
root.get(4).attributes,
"should wraparound within a collection");
});
module('list-hofs', {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
window.openerp.web.chrome(openerp);
// views loader stuff
window.openerp.web.data(openerp);
window.openerp.web.views(openerp);
window.openerp.web.list(openerp);
}
});
test('each, degenerate', function () {
var c = new openerp.web.list.Collection([
});
openerp.testing.section('list.collections.hom', {
dependencies: ['web.list']
}, function (test) {
test('each, degenerate', function (instance) {
var c = new instance.web.list.Collection([
{id: 1, value: 5},
{id: 2, value: 10},
{id: 3, value: 20}
@ -362,8 +324,8 @@ $(document).ready(function () {
ids, [1, 2, 3],
'degenerate collections should be iterated in record order');
});
test('each, deep', function () {
var root = new openerp.web.list.Collection(),
test('each, deep', function (instance) {
var root = new instance.web.list.Collection(),
ids = [];
root.proxy('foo').add([
{id: 1, value: 5},
@ -382,8 +344,8 @@ $(document).ready(function () {
ids, [1, 2, 3, 10, 20, 30],
'tree collections should be deeply iterated');
});
test('map, degenerate', function () {
var c = new openerp.web.list.Collection([
test('map, degenerate', function (instance) {
var c = new instance.web.list.Collection([
{id: 1, value: 5},
{id: 2, value: 10},
{id: 3, value: 20}
@ -395,8 +357,8 @@ $(document).ready(function () {
ids, [1, 2, 3],
'degenerate collections should be iterated in record order');
});
test('map, deep', function () {
var root = new openerp.web.list.Collection();
test('map, deep', function (instance) {
var root = new instance.web.list.Collection();
root.proxy('foo').add([
{id: 1, value: 5},
{id: 2, value: 10},
@ -414,29 +376,20 @@ $(document).ready(function () {
ids, [1, 2, 3, 10, 20, 30],
'tree collections should be deeply iterated');
});
module("list-weirds", {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
window.openerp.web.chrome(openerp);
// views loader stuff
window.openerp.web.data(openerp);
window.openerp.web.views(openerp);
window.openerp.web.list(openerp);
}
});
test('set-from-noid', function () {
var root = new openerp.web.list.Collection();
});
openerp.testing.section('list.collection.weirdoes', {
dependencies: ['web.list']
}, function (test) {
test('set-from-noid', function (instance) {
var root = new instance.web.list.Collection();
root.add({v: 3});
root.at(0).set('id', 42);
var record = root.get(42);
equal(root.length, 1);
equal(record.get('v'), 3, "should have fetched the original record");
});
test('set-from-previd', function () {
var root = new openerp.web.list.Collection();
test('set-from-previd', function (instance) {
var root = new instance.web.list.Collection();
root.add({id: 1, v: 2});
root.get(1).set('id', 42);
var record = root.get(42);

View File

@ -1,58 +1,55 @@
$(document).ready(function () {
var openerp;
module('Registry', {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
openerp.web.Foo = {};
openerp.web.Bar = {};
openerp.web.Foo2 = {};
}
});
test('key set', function () {
var reg = new openerp.web.Registry();
openerp.testing.section('registry', {
dependencies: ['web.corelib'],
setup: function (instance) {
instance.web.Foo = {};
instance.web.Bar = {};
instance.web.Foo2 = {};
}
}, function (test) {
test('key set', function (instance) {
var reg = new instance.web.Registry();
reg.add('foo', 'openerp.web.Foo')
.add('bar', 'openerp.web.Bar');
strictEqual(reg.get_object('bar'), openerp.web.Bar);
reg.add('foo', 'instance.web.Foo')
.add('bar', 'instance.web.Bar');
strictEqual(reg.get_object('bar'), instance.web.Bar);
});
test('extension', function () {
var reg = new openerp.web.Registry({
foo: 'openerp.web.Foo',
bar: 'openerp.web.Bar'
test('extension', function (instance) {
var reg = new instance.web.Registry({
foo: 'instance.web.Foo',
bar: 'instance.web.Bar'
});
var reg2 = reg.extend({ 'foo': 'openerp.web.Foo2' });
strictEqual(reg.get_object('foo'), openerp.web.Foo);
strictEqual(reg2.get_object('foo'), openerp.web.Foo2);
var reg2 = reg.extend({ 'foo': 'instance.web.Foo2' });
strictEqual(reg.get_object('foo'), instance.web.Foo);
strictEqual(reg2.get_object('foo'), instance.web.Foo2);
});
test('remain-linked', function () {
var reg = new openerp.web.Registry({
foo: 'openerp.web.Foo',
bar: 'openerp.web.Bar'
test('remain-linked', function (instance) {
var reg = new instance.web.Registry({
foo: 'instance.web.Foo',
bar: 'instance.web.Bar'
});
var reg2 = reg.extend();
reg.add('foo2', 'openerp.web.Foo2');
strictEqual(reg.get_object('foo2'), openerp.web.Foo2);
strictEqual(reg2.get_object('foo2'), openerp.web.Foo2);
reg.add('foo2', 'instance.web.Foo2');
strictEqual(reg.get_object('foo2'), instance.web.Foo2);
strictEqual(reg2.get_object('foo2'), instance.web.Foo2);
});
test('multiget', function () {
var reg = new openerp.web.Registry({
foo: 'openerp.web.Foo',
bar: 'openerp.web.Bar'
test('multiget', function (instance) {
var reg = new instance.web.Registry({
foo: 'instance.web.Foo',
bar: 'instance.web.Bar'
});
strictEqual(reg.get_any(['qux', 'grault', 'bar', 'foo']),
openerp.web.Bar);
instance.web.Bar);
});
test('extended-multiget', function () {
var reg = new openerp.web.Registry({
foo: 'openerp.web.Foo',
bar: 'openerp.web.Bar'
test('extended-multiget', function (instance) {
var reg = new instance.web.Registry({
foo: 'instance.web.Foo',
bar: 'instance.web.Bar'
});
var reg2 = reg.extend();
strictEqual(reg2.get_any(['qux', 'grault', 'bar', 'foo']),
openerp.web.Bar);
instance.web.Bar);
});
});

View File

@ -1,16 +1,8 @@
$(document).ready(function () {
var openerp;
module('Misordered resolution management', {
setup: function () {
openerp = window.openerp.init([]);
window.openerp.web.corelib(openerp);
window.openerp.web.coresetup(openerp);
window.openerp.web.data(openerp);
}
});
test('Resolve all correctly ordered, sync', function () {
var dm = new openerp.web.DropMisordered(), flag = false;
openerp.testing.section('misordered resolution managemeng', {
dependencies: ['web.data']
}, function (test) {
test('Resolve all correctly ordered, sync', function (instance) {
var dm = new instance.web.DropMisordered(), flag = false;
var d1 = $.Deferred(), d2 = $.Deferred(),
r1 = dm.add(d1), r2 = dm.add(d2);
@ -23,8 +15,8 @@ $(document).ready(function () {
ok(flag);
});
test("Don't resolve mis-ordered, sync", function () {
var dm = new openerp.web.DropMisordered(),
test("Don't resolve mis-ordered, sync", function (instance) {
var dm = new instance.web.DropMisordered(),
done1 = false, done2 = false,
fail1 = false, fail2 = false;
@ -44,8 +36,8 @@ $(document).ready(function () {
ok(done2);
ok(!fail2);
});
test('Fail mis-ordered flag, sync', function () {
var dm = new openerp.web.DropMisordered(true),
test('Fail mis-ordered flag, sync', function (instance) {
var dm = new instance.web.DropMisordered(true),
done1 = false, done2 = false,
fail1 = false, fail2 = false;
@ -66,8 +58,8 @@ $(document).ready(function () {
ok(!fail2);
});
asyncTest('Resolve all correctly ordered, async', 1, function () {
var dm = new openerp.web.DropMisordered();
test('Resolve all correctly ordered, async', {asserts: 1}, function (instance) {
var dm = new instance.web.DropMisordered();
var d1 = $.Deferred(), d2 = $.Deferred(),
r1 = dm.add(d1), r2 = dm.add(d2);
@ -75,13 +67,12 @@ $(document).ready(function () {
setTimeout(function () { d1.resolve(); }, 100);
setTimeout(function () { d2.resolve(); }, 200);
$.when(r1, r2).done(function () {
start();
return $.when(r1, r2).done(function () {
ok(true);
});
});
asyncTest("Don't resolve mis-ordered, async", 4, function () {
var dm = new openerp.web.DropMisordered(),
test("Don't resolve mis-ordered, async", {asserts: 4}, function (instance) {
var dm = new instance.web.DropMisordered(),
done1 = false, done2 = false,
fail1 = false, fail2 = false;
@ -94,18 +85,20 @@ $(document).ready(function () {
setTimeout(function () { d1.resolve(); }, 200);
setTimeout(function () { d2.resolve(); }, 100);
var done = $.Deferred();
setTimeout(function () {
start();
// d1 is in limbo
ok(!done1);
ok(!fail1);
// d2 is resolved
ok(done2);
ok(!fail2);
done.resolve();
}, 400);
return $.when(d1, d2, done);
});
asyncTest('Fail mis-ordered flag, async', 4, function () {
var dm = new openerp.web.DropMisordered(true),
test('Fail mis-ordered flag, async', {asserts: 4}, function (instance) {
var dm = new instance.web.DropMisordered(true),
done1 = false, done2 = false,
fail1 = false, fail2 = false;
@ -118,6 +111,7 @@ $(document).ready(function () {
setTimeout(function () { d1.resolve(); }, 200);
setTimeout(function () { d2.resolve(); }, 100);
var done = $.Deferred();
setTimeout(function () {
start();
// d1 is failed
@ -126,6 +120,8 @@ $(document).ready(function () {
// d2 is resolved
ok(done2);
ok(!fail2);
done.resolve();
}, 400);
return $.when(d1, d2, done)
});
});