mediawiki.language: Fix infinite loop in commafy() when pattern has no grouping

When the decimal part of the pattern has no grouping, commafy was entering
into an infinite loop. Corrected the logic to handle this case.

Also added qunit tests.

Bug: 69835
Change-Id: I0f9e274411aead6a4e95402fd38c54ac6b76df53
Merge "mediawiki.language: Fix infinite loop in commafy() when pattern has no grouping"