Calculators/Form calculators/Tests

*This is a page for testing MediaWiki:Common.js/calc.js.*

## Parameter tests

### article

This tests that search suggestions are enabled on article fields using `{{FormCalcTests/article}}`.

```
template  = Template:FormCalcTests/article
form      = fct-article
result    = fct-article-res
suggestns = 0
param     = page|article (autocomplete)||article
param     = page2|string (no autocomplete)||string

```

### number

This tests that numbers outside a specific range are recorded as errors using `{{FormCalcTests/number}}`

```
template = Template:FormCalcTests/number
form     = fct-number
result   = fct-number-res

```

### int

This tests that integers outside a specific range and decimals are recorded as errors using `{{FormCalcTests/int}}`

```
template = Template:FormCalcTests/int
form     = fct-int
result   = fct-int-res
param    = int3|Int (decimal)|4.2|int

```

### select

This tests the select input with and without a default value using `{{FormCalcTests/select}}`

```
template = Template:FormCalcTests/select
form     = fct-select
result   = fct-select-res

```

### check

This tests the checkbox input for default and custom true-false values using `{{FormCalcTests/check}}`

```
template = Template:FormCalcTests/check
form     = fct-check
result   = fct-check-res
param    = check|Check (true/false)||check

```

### hs

This tests the hs parameter type using `{{FormCalcTests/hs}}`

```
template  = Template:FormCalcTests/hs
form      = fct-hs
result    = fct-hs-res
suggestns = 0
param     = attack|Attack level|1|int
param     = defence|Defence level|1|int

```

### fixed

This tests the fixed parameter type using `{{FormCalcTests/fixed}}`

```
template  = Template:FormCalcTests/fixed
form      = fct-fixed
result    = fct-fixed-res
suggestns = 0
param     = fixed|Fixed|fixed|fixed
param     = string|String|changeable|string

```

### semihidden

This tests the semihidden input and custom true-false values using `{{FormCalcTests/semihidden}}`

```
template = Template:FormCalcTests/semihidden
form     = fct-semihidden
result   = fct-semihidden-res
param    = semi|Semihidden (hidden)|hidden|semihidden
param    = string|String (shown)|shown|string

```

To fully test this input:

* Submit once to see the output as "hidden"
* Paste the following js into your console: `$('#fct-semihidden-fct-semihidden-res-semi').val('changed');`
* Submit again and see the output as "changed

### label html (div tag)

This tests label sanitisation using `{{FormCalcTests/label}}`

template = Template:FormCalcTests/label
form = fct-label
result = fct-label-res
param = label|Random|A tag with href (wikitext)|fixed
param = label2|<a href="javascript:alert('xss weakness');">XSS</a>|A tag with script URL (escaped)|fixed
param = label3|<script>alert('xss weakness 2')</script>|Script tag (escaped)|fixed
param = label4|testing?|Text with additional span tag|fixed
param = label5|Font|Font tag (removed)|fixed

## label html (pre tag)

This tests label sanitisation using `{{FormCalcTests/label}}`

```
template = Template:FormCalcTests/label
form     = fct-label2
result   = fct-label2-res
param    = label|<a href="/wiki/Special:Random">Random</a>|A tag with href|fixed
param    = label2|<a href="javascript:alert('xss weakness');">XSS</a>|A tag with script URL|fixed
param    = label3|<script>alert('xss weakness 2')</script>|Script tag (removed)|fixed
param    = label4|testing<span title="help">?</span>|Text with additional span tag|fixed
param    = label5|<font>Font</font>|Font tag (removed)|fixed

```