[REF] sms: adapt code after jQuery update
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
This commit is contained in:
committed by
Aaron Bohy
co-authored by
Aaron Bohy
Christophe Matthieu
Mathieu Duckerts-Antoine
David Monjoie
Martin Geubelle
svs-odoo
parent
624c943806
commit
b9065324e9
@@ -24,41 +24,49 @@ QUnit.module('fields', {
|
||||
|
||||
QUnit.module('SmsWidget');
|
||||
|
||||
QUnit.test('Sms widgets are correctly rendered', function (assert) {
|
||||
QUnit.test('Sms widgets are correctly rendered', async function (assert) {
|
||||
assert.expect(9);
|
||||
var form = createView({
|
||||
var form = await createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<form><sheet><field name="message" widget="sms_widget"/></sheet></form>',
|
||||
});
|
||||
assert.ok(form.$('.o_sms_count').length, "Should have a sms counter");
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '0 chars, fits in 0 SMS (GSM7) ', 'Should be "0 chars, fits in 0 SMS (GSM7) " by default');
|
||||
assert.containsOnce(form, '.o_sms_count', "Should have a sms counter");
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '0 chars, fits in 0 SMS (GSM7) ',
|
||||
'Should be "0 chars, fits in 0 SMS (GSM7) " by default');
|
||||
// GSM-7
|
||||
form.$('.o_input').val("Hello from Odoo").trigger('input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '15 chars, fits in 1 SMS (GSM7) ', 'Should be "15 chars, fits in 1 SMS (GSM7) " for "Hello from Odoo"');
|
||||
await testUtils.fields.editAndTrigger(form.$('.o_input'), "Hello from Odoo", 'input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '15 chars, fits in 1 SMS (GSM7) ',
|
||||
'Should be "15 chars, fits in 1 SMS (GSM7) " for "Hello from Odoo"');
|
||||
// GSM-7 with \n => this one count as 2 characters
|
||||
form.$('.o_input').val("Hello from Odoo\n").trigger('input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '17 chars, fits in 1 SMS (GSM7) ', 'Should be "17 chars, fits in 1 SMS (GSM7) " for "Hello from Odoo\\n"');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '17 chars, fits in 1 SMS (GSM7) ',
|
||||
'Should be "17 chars, fits in 1 SMS (GSM7) " for "Hello from Odoo\\n"');
|
||||
// Unicode => ê
|
||||
form.$('.o_input').val("Hêllo from Odoo").trigger('input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '15 chars, fits in 1 SMS (UNICODE) ', 'Should be "15 chars, fits in 1 SMS (UNICODE) " for "Hêllo from Odoo"');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '15 chars, fits in 1 SMS (UNICODE) ',
|
||||
'Should be "15 chars, fits in 1 SMS (UNICODE) " for "Hêllo from Odoo"');
|
||||
// GSM-7 with 160c
|
||||
var text = Array(161).join('a');
|
||||
form.$('.o_input').val(text).trigger('input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '160 chars, fits in 1 SMS (GSM7) ', 'Should be "160 chars, fits in 1 SMS (GSM7) " for 160 x "a"');
|
||||
await testUtils.fields.editAndTrigger(form.$('.o_input'), text, 'input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '160 chars, fits in 1 SMS (GSM7) ',
|
||||
'Should be "160 chars, fits in 1 SMS (GSM7) " for 160 x "a"');
|
||||
// GSM-7 with 161c
|
||||
text = Array(162).join('a');
|
||||
form.$('.o_input').val(text).trigger('input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '161 chars, fits in 2 SMS (GSM7) ', 'Should be "161 chars, fits in 2 SMS (GSM7) " for 161 x "a"');
|
||||
await testUtils.fields.editAndTrigger(form.$('.o_input'), text, 'input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '161 chars, fits in 2 SMS (GSM7) ',
|
||||
'Should be "161 chars, fits in 2 SMS (GSM7) " for 161 x "a"');
|
||||
// Unicode with 70c
|
||||
text = Array(71).join('ê');
|
||||
form.$('.o_input').val(text).trigger('input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '70 chars, fits in 1 SMS (UNICODE) ', 'Should be "70 chars, fits in 1 SMS (UNICODE) " for 70 x "ê"');
|
||||
await testUtils.fields.editAndTrigger(form.$('.o_input'), text, 'input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '70 chars, fits in 1 SMS (UNICODE) ',
|
||||
'Should be "70 chars, fits in 1 SMS (UNICODE) " for 70 x "ê"');
|
||||
// Unicode with 71c
|
||||
text = Array(72).join('ê');
|
||||
form.$('.o_input').val(text).trigger('input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '71 chars, fits in 2 SMS (UNICODE) ', 'Should be "71 chars, fits in 2 SMS (UNICODE) " for 71 x "ê"');
|
||||
await testUtils.fields.editAndTrigger(form.$('.o_input'), text, 'input');
|
||||
assert.strictEqual(form.$('.o_sms_count').text(), '71 chars, fits in 2 SMS (UNICODE) ',
|
||||
'Should be "71 chars, fits in 2 SMS (UNICODE) " for 71 x "ê"');
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user