From 6fcfb7c04d32e1c8b26a312295bf7ac3ec2d2ad7 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Fri, 13 Jul 2018 19:06:45 +0200
Subject: Fixed many permissions and began admin interface
---
.../select2/tests/data/array-tests.js | 318 +++++++++++++++++++++
1 file changed, 318 insertions(+)
create mode 100644 public/bower_components/select2/tests/data/array-tests.js
(limited to 'public/bower_components/select2/tests/data/array-tests.js')
diff --git a/public/bower_components/select2/tests/data/array-tests.js b/public/bower_components/select2/tests/data/array-tests.js
new file mode 100644
index 0000000..65a6e32
--- /dev/null
+++ b/public/bower_components/select2/tests/data/array-tests.js
@@ -0,0 +1,318 @@
+module('Data adapters - Array');
+
+var ArrayData = require('select2/data/array');
+var $ = require('jquery');
+var Options = require('select2/options');
+
+var arrayOptions = new Options({
+ data: [
+ {
+ id: 'default',
+ text: 'Default'
+ },
+ {
+ id: '1',
+ text: 'One'
+ },
+ {
+ id: '2',
+ text: '2'
+ }
+ ]
+});
+
+var extraOptions = new Options ({
+ data: [
+ {
+ id: 'default',
+ text: 'Default',
+ extra: true
+ },
+ {
+ id: 'One',
+ text: 'One',
+ extra: true
+ }
+ ]
+});
+
+var nestedOptions = new Options({
+ data: [
+ {
+ text: 'Default',
+ children: [
+ {
+ text: 'Next',
+ children: [
+ {
+ id: 'a',
+ text: 'Option'
+ }
+ ]
+ }
+ ]
+ }
+ ]
+});
+
+test('current gets default for single', function (assert) {
+ var $select = $('#qunit-fixture .single-empty');
+
+ var data = new ArrayData($select, arrayOptions);
+
+ data.current(function (val) {
+ assert.equal(
+ val.length,
+ 1,
+ 'There should always be a selected item for array data.'
+ );
+
+ var item = val[0];
+
+ assert.equal(
+ item.id,
+ 'default',
+ 'The first item should be selected'
+ );
+ });
+});
+
+test('current gets default for multiple', function (assert) {
+ var $select = $('#qunit-fixture .multiple');
+
+ var data = new ArrayData($select, arrayOptions);
+
+ data.current(function (val) {
+ assert.equal(
+ val.length,
+ 0,
+ 'There should be no default selection.'
+ );
+ });
+});
+
+test('current works with existing selections', function (assert) {
+ var $select = $('#qunit-fixture .multiple');
+
+ var data = new ArrayData($select, arrayOptions);
+
+ $select.val(['One']);
+
+ data.current(function (val) {
+ assert.equal(
+ val.length,
+ 1,
+ 'There should only be one existing selection.'
+ );
+
+ var option = val[0];
+
+ assert.equal(
+ option.id,
+ 'One',
+ 'The id should be equal to the value of the option tag.'
+ );
+
+ assert.equal(
+ option.text,
+ 'One',
+ 'The text should be equal to the text of the option tag.'
+ );
+ });
+});
+
+test('current works with selected data', function (assert) {
+ var $select = $('#qunit-fixture .single-empty');
+
+ var data = new ArrayData($select, arrayOptions);
+
+ data.select({
+ id: '2',
+ text: '2'
+ });
+
+ data.current(function (val) {
+ assert.equal(
+ val.length,
+ 1,
+ 'There should only be one option selected.'
+ );
+
+ var option = val[0];
+
+ assert.equal(
+ option.id,
+ '2',
+ 'The id should match the original id from the array.'
+ );
+
+ assert.equal(
+ option.text,
+ '2',
+ 'The text should match the original text from the array.'
+ );
+ });
+});
+
+test('select works for single', function (assert) {
+ var $select = $('#qunit-fixture .single-empty');
+
+ var data = new ArrayData($select, arrayOptions);
+
+ assert.equal(
+ $select.val(),
+ 'default',
+ 'There should already be a selection'
+ );
+
+ data.select({
+ id: '1',
+ text: 'One'
+ });
+
+ assert.equal(
+ $select.val(),
+ '1',
+ 'The selected value should be the same as the selected id'
+ );
+});
+
+test('multiple sets the value', function (assert) {
+ var $select = $('#qunit-fixture .multiple');
+
+ var data = new ArrayData($select, arrayOptions);
+
+ assert.equal($select.val(), null);
+
+ data.select({
+ id: 'default',
+ text: 'Default'
+ });
+
+ assert.deepEqual($select.val(), ['default']);
+});
+
+test('multiple adds to the old value', function (assert) {
+ var $select = $('#qunit-fixture .multiple');
+
+ var data = new ArrayData($select, arrayOptions);
+
+ $select.val(['One']);
+
+ assert.deepEqual($select.val(), ['One']);
+
+ data.select({
+ id: 'default',
+ text: 'Default'
+ });
+
+ assert.deepEqual($select.val(), ['One', 'default']);
+});
+
+test('option tags are automatically generated', function (assert) {
+ var $select = $('#qunit-fixture .single-empty');
+
+ var data = new ArrayData($select, arrayOptions);
+
+ assert.equal(
+ $select.find('option').length,
+ 3,
+ 'An