mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
jsonx tests updated.
This commit is contained in:
Vendored
+2
-1
@@ -1,8 +1,9 @@
|
||||
// Type definitions for JSnoX
|
||||
// Project: https://github.com/af/jsnox
|
||||
// Definitions by: Steve Baker <https://github.com/stkb/>
|
||||
// Dovydas Navickas <https://github.com/DovydasNavickas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="react" />
|
||||
|
||||
|
||||
+37
-38
@@ -1,57 +1,56 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import * as jsnox from 'jsnox';
|
||||
var $ = jsnox(React);
|
||||
import * as React from "react";
|
||||
import * as jsnox from "jsnox";
|
||||
let $ = jsnox(React);
|
||||
|
||||
interface PersonProps {
|
||||
firstName: string
|
||||
lastName: string
|
||||
age: number
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
age: number;
|
||||
}
|
||||
|
||||
var Person = React.createClass<PersonProps, {}>({
|
||||
render():React.ReactElement<any> { return null; }
|
||||
let Person: React.ClassicComponentClass<PersonProps> = React.createClass<PersonProps, {}>({
|
||||
render(): React.ReactElement<any> { return null; }
|
||||
});
|
||||
|
||||
var PersonTag = React.createFactory(Person);
|
||||
let PersonTag = React.createFactory(Person);
|
||||
|
||||
var clickHandler: React.MouseEventHandler<{}>;
|
||||
let clickHandler: React.MouseEventHandler<{}>;
|
||||
|
||||
// Tests with spec string
|
||||
function spec_string () {
|
||||
var result: React.ReactHTMLElement<HTMLElement>
|
||||
// tests with spec string
|
||||
function spec_string(): void {
|
||||
let result: React.DOMElement<React.DOMAttributes<Element>, Element>;
|
||||
|
||||
// just spec string
|
||||
result = $('div')
|
||||
result = $("div");
|
||||
|
||||
// No properties, just children
|
||||
result = $('div', 'hello') // one string child
|
||||
result = $('div', $('span', 'world')) // one element child
|
||||
result = $('div', ['hello', $('span', 'world')]) // mixed array of children
|
||||
// no properties, just children
|
||||
result = $("div", "hello"); // one string child
|
||||
result = $("div", $("span", "world")); // one element child
|
||||
result = $("div", ["hello", $("span", "world")]); // mixed array of children
|
||||
|
||||
// With html properties
|
||||
result = $('div', { onClick: clickHandler }) // no children
|
||||
result = $('div', { onClick: clickHandler }, 'hello') // one string child
|
||||
result = $('div', { onClick: clickHandler }, $('span', 'world')) // one element child
|
||||
result = $('div', { onClick: clickHandler }, ['hello', $('span', 'world')]) // mixed array of children
|
||||
// with html properties
|
||||
result = $("div", { onClick: clickHandler }); // no children
|
||||
result = $("div", { onClick: clickHandler }, "hello"); // one string child
|
||||
result = $("div", { onClick: clickHandler }, $("span", "world")); // one element child
|
||||
result = $("div", { onClick: clickHandler }, ["hello", $("span", "world")]); // mixed array of children
|
||||
}
|
||||
|
||||
// Tests with react component
|
||||
function react_component() {
|
||||
var result: React.ReactElement<{}>
|
||||
// tests with react component
|
||||
function react_component(): void {
|
||||
let result: React.ReactElement<{}>;
|
||||
|
||||
// with nothing more
|
||||
result = $(Person)
|
||||
result = $(Person);
|
||||
|
||||
// No properties, just children
|
||||
result = $(Person, 'hello') // one string child
|
||||
result = $(Person, $('span', 'world')) // one element child
|
||||
result = $(Person, ['hello', $('span', 'world')]) // mixed array of children
|
||||
// no properties, just children
|
||||
result = $(Person, "hello"); // one string child
|
||||
result = $(Person, $("span", "world")); // one element child
|
||||
result = $(Person, ["hello", $("span", "world")]); // mixed array of children
|
||||
|
||||
// With component props
|
||||
var props = { firstName: 'Bob', lastName: 'Garfield', age: 72 }
|
||||
result = $(Person, props) // no children
|
||||
result = $(Person, props, 'hello') // one string child
|
||||
result = $(Person, props, $('span', 'world')) // one element child
|
||||
result = $(Person, props, ['hello', PersonTag()]) // mixed array of children
|
||||
// with component props
|
||||
let props: PersonProps = { firstName: "Bob", lastName: "Garfield", age: 72 };
|
||||
result = $(Person, props); // no children
|
||||
result = $(Person, props, "hello"); // one string child
|
||||
result = $(Person, props, $("span", "world")); // one element child
|
||||
result = $(Person, props, ["hello", PersonTag()]); // mixed array of children
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user