quailjs/quail — pull request #273 by mlewand (2014-09-16 09:57:43+00:00)
Title: KINGUseLongDateFormat is checking whole innerText of the element

# Problem

This is a follow-up of a #272 issue.

Currently test **KINGUseLongDateFormat** is checking whole innerText of inspecting element by calling ```quail.getTextContents()```.

1. When we'll add a ```li``` element to the KINGUseLongDateFormat [inspected element selector](https://github.com/quailjs/quail/blob/589eb65dc73b8ed2c35f1d4c5d880e79677b9fc1/src/js/custom/KINGUseLongDateFormat.js#L19) it would check innerText of both ```li``` and its ```p``` elements.

That will result in extra failure cases. See TC1.

2. Also this change will make results more accurate, since case ```element``` will point to direct parent, rather than element which is very likely not to be an element which contains invalid text.

3. Finally it will allow to be more specific about issues count.

## Sample TC

**TC1.** Consider following HTML to be checked by the Quail:

```

Short date 12-04-12

```

**Expected result:**
Quail should produce **1** fialed cases.
Case should be created only for the ```p``` element.

**Current result:**
Quail produces only **2** failed case.
First for the ```li``` element and second for the ```p``` element.

## Proposed solution

Solution in pull request will restrict checking to direct TextNode children.

## Additional notes

Proposed solution has an issue not present in original approach, that is it doesn't detecting "non-visible breakers".

By that I mean elements, which doesn't really have any text content in it. Eg.

```

Short date 10.02.2011

```

Here ideally we'd like ```span``` to be ignored, and case still be failed.

We already solved this issue, however it adds some complexity to the code, so we'd like to propose this simplified solution first. If you're fine with this change, we'll send next pull request fixing this problem too.

## Complete test

Assuming that the KINGUseLongDateFormat [selector](https://github.com/quailjs/quail/blob/589eb65dc73b8ed2c35f1d4c5d880e79677b9fc1/src/js/custom/KINGUseLongDateFormat.js#L19) is changed to:

* match also ```li```
* not match ```font``` tag

So it might look like: ```test.get('$scope').find('p, li').each(testDateFormat);```

You might use following [gist file](https://gist.github.com/mlewand/ebdb9ff72c74f6c74bc1) to test TC1 problem.

Just put it into quail directory (requires builded Quail, since it uses ```dist```).