Skip to content

Commit

Permalink
Merge pull request #32 from rachelnicole/plugin-tests
Browse files Browse the repository at this point in the history
Plugin Fixtures
  • Loading branch information
scottnath authored Jun 16, 2016
2 parents 6e306fc + fda6196 commit 726489e
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/fixtures/input-plugins/input-plugin-checkbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const validation = require('./lib/validation.js');

module.exports = {
name: 'Checkbox Selector',
description: 'Select items',
validation: {
checkboxValidation: validation,
},
inputs: {
checkboxSelector: {
validation: {
function: 'checkboxValidation',
on: 'blur',
},
label: 'Select items',
type: 'checkbox',
options: [
{ label: 'red',
value: 'red',
},
{ label: 'blue',
value: 'blue',
},
{ label: 'green',
value: 'green',
},
{ label: 'yellow',
value: 'yellow',
},
],
settings: {
empty: false
},
},
},
html: `<label for="{{checkboxSelector.id}}">{{checkboxSelector.label}}</label>{% for option in checkboxSelector.options %}<label><input type="{{checkboxSelector.type}}" name={{checkboxSelector.name}} id="{{checkboxSelector.id}}" value="{{checkboxSelector.value}}" {% if option.value == checkboxSelector.value %}checked{% endif %}>{{option.label}}</label>{% endfor %}`,
};
27 changes: 27 additions & 0 deletions tests/fixtures/input-plugins/input-plugin-multiple-select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const validation = require('./lib/validation.js');

module.exports = {
name: 'Multiple Kitten Name Selector',
description: 'Select a few kitten names',
validation: {
kittenNameMultipleSelectorValidation: validation,
},
inputs: {
kittenNameSelector: {
validation: {
function: 'kittenNameMultipleSelectorValidation',
on: 'blur',
},
label: 'Select a few kitten names',
type: 'select',
settings: {
empty: false,
multiple: true,
names: ['Michaelangelo', 'Leonardo', 'Raphael', 'Donatello', 'Muffins', 'Jeff']
},
},
},
html: `<label for="{{kittenNameSelector.id}}">{{kittenNameSelector.label}}<select id="{{kittenNameSelector.id}}" name="{{kittenNameSelector.name}}" value="{{kittenNameSelector.value}}" {% if settings.multiple %}multiple="multiple"{% endif %}>
{% for name in kittenNameSelector.settings.name %}<option value="{{name}}" {% if name == kittenNameSelector.value %}selected{% endif %}>{{name}}</option>{% endfor %}
</select></label>`,
};
25 changes: 25 additions & 0 deletions tests/fixtures/input-plugins/input-plugin-range.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const validation = require('./lib/validation.js');

module.exports = {
name: 'Range Selector',
description: 'Select a range',
validation: {
rangeValidation: validation,
},
inputs: {
rangeSelector: {
validation: {
function: 'rangeValidation',
on: 'blur',
},
label: 'Select a range',
type: 'range',
settings: {
empty: true,
min: 1,
max: 5
},
},
},
html: `<label for="{{rangeSelector.id}}">{{rangeSelector.label}}</label><input type="{{rangeSelector.type}}" id="{{rangeSelector.id}}" name="{{rangeSelector.name}}" min="{{rangeSelector.settings.min}}" max="{{rangeSelector.settings.max}}" value="{{rangeSelector.value}}"/>`,
};

0 comments on commit 726489e

Please sign in to comment.