<!-- This template is used for testing Javascript functions

Run by opening this URL: http://localhost:8000/moonmining/tests
-->

{% extends 'moonmining/base.html' %}
{% load i18n %}
{% load static %}

{% block details %}
    <h1>Javascript Tests</h1>
    <div id="testResults"></div>
{% endblock %}

{% block extra_javascript %}
    {{ block.super }}
    <script type="text/javascript">
        function assertTrue(testName, expr){
            $('#testResults').append(
                '<p>'
                + testName
                + ": "
                + (expr ? '<span style="color:green;">OK</span>' : '<span style="color:red;">FAILED</span>')
                + '</p>'
            )
        }

        assertTrue("formatisk_k1", formatisk(1000)=='1.0k')
        assertTrue("formatisk_k2", formatisk(1100)=='1.1k')
        assertTrue("formatisk_z1", formatisk(1)=='1.0')
        assertTrue("formatisk_z2", formatisk(0)=='0.0')
        assertTrue("formatisk_custom_1", formatisk(1100000, 'k')=='1,100.0k')
    </script>
{% endblock %}
