Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Commit

Permalink
Add test case for placeholders in Selectivity instances initialized w…
Browse files Browse the repository at this point in the history
…ith the traditional plugin.
  • Loading branch information
arendjr committed Nov 18, 2016
1 parent f9c90af commit b8f9ddc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions demos/demos-jquery.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

/* global $, Selectivity */
/* global $ */

function escape(string) {
return string ? String(string).replace(/[&<>"']/g, function(match) {
Expand Down Expand Up @@ -42,7 +42,7 @@ $(document).ready(function() {
};
}).get();

var transformText = Selectivity.transformText;
var transformText = $.Selectivity.transformText;

// example query function that returns at most 10 cities matching the given text
function queryFunction(query) {
Expand Down
18 changes: 18 additions & 0 deletions tests/resources/testcase-traditional-multiple-placeholder.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>Selectivity.js Test Case</title>
</head>
<body>
<h1>Select something</h1>
<p>
<select data-placeholder="Select one or more" id="selectivity-input" multiple name="my_select">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
</select>
</p>
</body>
</html>

17 changes: 17 additions & 0 deletions tests/unit/jquery/traditional.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,20 @@ TestUtil.createJQueryTest(
test.deepEqual($input.selectivity('value'), ['3', '4', '1', '2']);
}
);

TestUtil.createJQueryTest(
'jquery/traditional: test placeholder with multiple select input',
['inputs/multiple', 'plugins/jquery/traditional', 'templates'],
{ indexResource: 'testcase-traditional-multiple-placeholder.html' },
function(test, $input, $) {
$input.selectivity();

test.deepEqual($input.selectivity('data'), []);
test.equal($('select[name="my_select"] option[selected]').length, 0);
test.equal($('.multiple-selected-item').length, 0);

var input = $('.selectivity-multiple-input')[0];
test.equal(input.value, '');
test.equal(input.getAttribute('placeholder'), 'Select one or more');
}
);

0 comments on commit b8f9ddc

Please sign in to comment.