#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test of TypeScript JSX support.

cat <<\EOF > xg-ts-6.tsx
import React from 'react';
type FooProps = {};
type FooState = {};
class Foo extends React.Component<FooProps, FooState> {
    render() {
        return <div className="aClass" />;
    }
}
type BarProps = {};
type BarState = {};
class Bar extends React.Component<BarProps, BarState> {
    render() {
        return (
            <div>
                <span className="someClass" />
                { gettext('Expected translation string #0') }
            </div>
        );
    }
}
const x1 = <x1></x1>;
const s1: string = _("Expected translation string #1");
const s2: string = "foo";
const x2 = React.createElement(s2 as any, null, `foo ${s2} bar`);
const x3 = (
    <x3 a1="/">
        <x4>{_("Expected translation string #2")}</x4>
    </x3>
);
const x4 = (
    <x5 a2="/">
        {React.createElement(_("Expected translation string #3") as any)}
    </x5>
);
const s9: string = _("Expected translation string #8");
function fooFunction() {
    return <a>{'b'}</a>;
}
const s10: string = _("Expected translation string #9");
// Mixing JSX with template literals.
const s11 = 0;
const s12 = (
    <div>
        {_("Expected translation string #10")}
        {`${_("Expected translation string #11")}`}
        {_("Expected translation string #12")}
    </div>
);
const s13: string = _("Expected translation string #13");
const s14 = <div className={`${_("Expected translation string #14")}`} />;
const s15: string = _("Expected translation string #15");
const s16 = { a: 1, b: <div className={`${_("Expected translation string #16")}`} /> };
const s17: string = _("Expected translation string #17");
const s18 = `begin${<div>{_("Expected translation string #18")}</div>}end`;
const s19: string = _("Expected translation string #19");
const s20 = () => (
    <Foo
        a1={_("Expected translation string #20")}
        a2={foo && <div>{_("Expected translation string #21")}</div>}
        a3={_("Expected translation string #22")}
    />
);
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} --add-comments --no-location -o xg-ts-6.tmp xg-ts-6.tsx 2>xg-ts-6.err
test $? = 0 || { cat xg-ts-6.err; Exit 1; }
func_filter_POT_Creation_Date xg-ts-6.tmp xg-ts-6.pot

cat <<\EOF > xg-ts-6.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "Expected translation string #0"
msgstr ""

msgid "Expected translation string #1"
msgstr ""

msgid "Expected translation string #2"
msgstr ""

msgid "Expected translation string #3"
msgstr ""

msgid "Expected translation string #8"
msgstr ""

msgid "Expected translation string #9"
msgstr ""

msgid "Expected translation string #10"
msgstr ""

msgid "Expected translation string #11"
msgstr ""

msgid "Expected translation string #12"
msgstr ""

msgid "Expected translation string #13"
msgstr ""

msgid "Expected translation string #14"
msgstr ""

msgid "Expected translation string #15"
msgstr ""

msgid "Expected translation string #16"
msgstr ""

msgid "Expected translation string #17"
msgstr ""

msgid "Expected translation string #18"
msgstr ""

msgid "Expected translation string #19"
msgstr ""

msgid "Expected translation string #20"
msgstr ""

msgid "Expected translation string #21"
msgstr ""

msgid "Expected translation string #22"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-ts-6.ok xg-ts-6.pot
result=$?

exit $result
