# Path: test/_common.py
# def print_test_result(expected, actual, error=None):
#     print(f"[expected]\n{expected}\n")
#     print(f"[actual]\n{actual}\n")
# 
#     if error:
#         print(error, file=sys.stderr)
# 
#     print("----------------------------------------")
# 
# Path: test/data.py
# TIME = datetime.datetime(2017, 1, 1, 0, 0, 0)
# INF = float("inf")
# NAN = float("nan")


import collections
import datetime
import pytest
import typepy
import pytablewriter
from textwrap import dedent
from ...._common import print_test_result
from ....data import (
    headers,
    mix_header_list,
    mix_value_matrix,
    value_matrix,
    value_matrix_iter,
    value_matrix_with_none,
)
                    """\
                    const typehint_datetime_string = [
                        ["string", "datetime"],
                        [new Date("2017-01-02T03:04:05"), "2017-01-02 03:04:05"],
                        [new Date("2017-01-02T03:04:05"), "2017-01-02 03:04:05"]
                    ];
                    """
                ),
            ],
        ],
    )
    def test_normal(self, capsys, table, header, value, type_hint, expected):
        writer = table_writer_class()
        writer.table_name = table
        writer.headers = header
        writer.value_matrix = value
        writer.type_hints = type_hint

        writer.write_table()

        out, err = capsys.readouterr()
        print_test_result(expected=expected, actual=out, error=err)

        assert out == expected
        assert writer.dumps() == expected
        assert str(writer) == expected

        # margin setting must be ignored
        writer.margin = 1
        out = writer.dumps()

# Path: test/_common.py
# def print_test_result(expected, actual, error=None):
#     print(f"[expected]\n{expected}\n")
#     print(f"[actual]\n{actual}\n")
# 
#     if error:
#         print(error, file=sys.stderr)
# 
#     print("----------------------------------------")
# 
# Path: test/data.py
# TIME = datetime.datetime(2017, 1, 1, 0, 0, 0)
# INF = float("inf")
# NAN = float("nan")


# Path: test/writer/text/sourcecode/test_javascript_writer.py
import collections
import datetime
import pytest
import typepy
import pytablewriter
from textwrap import dedent
from ...._common import print_test_result
from ....data import (
    headers,
    mix_header_list,
    mix_value_matrix,
    value_matrix,
    value_matrix_iter,
    value_matrix_with_none,
)

                    """\
                    const typehint_datetime_string = [
                        ["string", "datetime"],
                        [new Date("2017-01-02T03:04:05"), "2017-01-02 03:04:05"],
                        [new Date("2017-01-02T03:04:05"), "2017-01-02 03:04:05"]
                    ];
                    """
                ),
            ],
        ],
    )
    def test_normal(self, capsys, table, header, value, type_hint, expected):
        writer = table_writer_class()
        writer.table_name = table
        writer.headers = header
        writer.value_matrix = value
        writer.type_hints = type_hint

        writer.write_table()

        out, err = capsys.readouterr()
        print_test_result(expected=expected, actual=out, error=err)

        assert out == expected
        assert writer.dumps() == expected
        assert str(writer) == expected

        # margin setting must be ignored
        writer.margin = 1
        out = writer.dumps()

        print_test_result(expected=expected, actual=out)