Add assert-equal-jsx (#15884)

This commit is contained in:
Josh Toft 2017-04-20 07:17:36 -07:00 committed by Andy
parent c59b52e585
commit a15b6bf327
4 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import * as React from 'react';
import assertEqualJSX = require('assert-equal-jsx');
function sanitizeId(str: string): string {
return str.replace(/my-component-id-(\d+)/ig, 'my-component-id-0');
}
assertEqualJSX(
<div id='my-component-id-314159265' />,
// should equal:
<div id='my-component-id-0' />,
// with sanitization:
{
sanitize: sanitizeId
}
);

17
types/assert-equal-jsx/index.d.ts vendored Normal file
View File

@ -0,0 +1,17 @@
// Type definitions for assert-equal-jsx 1.0
// Project: https://github.com/thejameskyle/assert-equal-jsx
// Definitions by: Josh Toft <https://github.com/seryl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import * as React from 'react';
declare namespace assertEqualJSX {
interface AsssertOptions {
sanitize?(str: string): string;
}
}
declare function assertEqualJSX(actual: JSX.Element, expected: JSX.Element, opts?: assertEqualJSX.AsssertOptions): void;
export = assertEqualJSX;

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"assert-equal-jsx-tests.tsx"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }