Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@quilted/react-testing

Package Overview
Dependencies
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@quilted/react-testing - npm Package Compare versions

Comparing version 0.0.0-preview-20231104064716 to 0.0.0-preview-20231104071931

build/esm/matchers/components.mjs

20

build/typescript/matchers.d.ts
import type { ComponentType, Context as ReactContext } from 'react';
import type { PropsFor } from './types.ts';
import { matchers, domMatchers, type CustomDOMMatchers } from '@quilted/preact-testing/matchers';
import { toContainReactHTML, toHaveReactDataProps } from './matchers/dom.ts';
import { toHaveReactProps } from './matchers/props.ts';
import { toContainReactComponent, toContainReactComponentTimes } from './matchers/components.ts';
import { toContainReactText } from './matchers/text.ts';
import { toProvideReactContext } from './matchers/context.ts';
export interface CustomMatchers<R = unknown> {

@@ -10,4 +14,16 @@ toHaveReactProps(props: Record<string, unknown>): void;

toContainReactText(text: string): R;
toContainReactHTML(text: string): R;
toHaveReactDataProps(data: {
[key: string]: string;
}): R;
}
export { matchers, domMatchers, type CustomDOMMatchers };
export declare const matchers: {
toHaveReactProps: typeof toHaveReactProps;
toContainReactComponent: typeof toContainReactComponent;
toContainReactComponentTimes: typeof toContainReactComponentTimes;
toProvideReactContext: typeof toProvideReactContext;
toContainReactText: typeof toContainReactText;
toContainReactHTML: typeof toContainReactHTML;
toHaveReactDataProps: typeof toHaveReactDataProps;
};
//# sourceMappingURL=matchers.d.ts.map

6

build/typescript/matchers/components.d.ts
import type { ComponentType } from 'react';
import type { MatcherState } from 'expect';
import type { MatcherState, MatcherUtils } from 'expect';
import { Node, PropsFor } from '../types.ts';
export declare function toContainReactComponent<Type extends string | ComponentType<any>>(this: MatcherState, node: Node<any, any>, type: Type, props?: Partial<PropsFor<Type>>): {
export declare function toContainReactComponent<Type extends string | ComponentType<any>>(this: MatcherState & MatcherUtils, node: Node<any, any>, type: Type, props?: Partial<PropsFor<Type>>): {
pass: boolean;
message: () => string;
};
export declare function toContainReactComponentTimes<Type extends string | ComponentType<any>>(this: MatcherState, node: Node<unknown>, type: Type, times: number, props?: Partial<PropsFor<Type>>): {
export declare function toContainReactComponentTimes<Type extends string | ComponentType<any>>(this: MatcherState & MatcherUtils, node: Node<unknown>, type: Type, times: number, props?: Partial<PropsFor<Type>>): {
pass: boolean;

@@ -10,0 +10,0 @@ message: () => string;

@@ -1,2 +0,2 @@

import type { MatcherState } from 'expect';
import type { MatcherState, MatcherUtils } from 'expect';
import type { Node, HTMLNodeExtensions } from '../types.ts';

@@ -7,3 +7,3 @@ export declare function toContainReactHTML<Props>(this: MatcherState, node: Node<Props, HTMLNodeExtensions>, text: string): {

};
export declare function toHaveReactDataProps(this: MatcherState, node: Node<unknown>, data: {
export declare function toHaveReactDataProps(this: MatcherState & MatcherUtils, node: Node<unknown>, data: {
[key: string]: string;

@@ -10,0 +10,0 @@ }): {

@@ -1,4 +0,4 @@

import type { MatcherState } from 'expect';
import type { MatcherState, MatcherUtils } from 'expect';
import type { Node } from '../types.ts';
export declare function toHaveReactProps<Props>(this: MatcherState, node: Node<Props, any>, props: Partial<Props>): {
export declare function toHaveReactProps<Props>(this: MatcherState & MatcherUtils, node: Node<Props, any>, props: Partial<Props>): {
pass: boolean;

@@ -5,0 +5,0 @@ message: () => string;

@@ -16,4 +16,5 @@ import type { ComponentType } from 'react';

}): string | null;
export declare function getObjectSubset(object: any, subset: any): any;
export declare function pluralize(word: string, count: number): string;
export declare function printReceivedWithHighlight(text: string, start: number, length: number): string;
//# sourceMappingURL=utilities.d.ts.map
# @quilted/react-testing
## 0.0.0-preview-20231104064716
## 0.0.0-preview-20231104071931

@@ -10,3 +10,3 @@ ### Patch Changes

- Updated dependencies []:
- @quilted/preact-testing@0.0.0-preview-20231104064716
- @quilted/preact-testing@0.0.0-preview-20231104071931

@@ -13,0 +13,0 @@ ## 0.6.1

{
"name": "@quilted/react-testing",
"type": "module",
"version": "0.0.0-preview-20231104064716",
"version": "0.0.0-preview-20231104071931",
"repository": {

@@ -63,3 +63,3 @@ "type": "git",

"dependencies": {
"@quilted/preact-testing": "0.0.0-preview-20231104064716",
"@quilted/preact-testing": "0.0.0-preview-20231104071931",
"jest-matcher-utils": "^27.0.0"

@@ -66,0 +66,0 @@ },

@@ -5,7 +5,10 @@ import type {ComponentType, Context as ReactContext} from 'react';

import {toContainReactHTML, toHaveReactDataProps} from './matchers/dom.ts';
import {toHaveReactProps} from './matchers/props.ts';
import {
matchers,
domMatchers,
type CustomDOMMatchers,
} from '@quilted/preact-testing/matchers';
toContainReactComponent,
toContainReactComponentTimes,
} from './matchers/components.ts';
import {toContainReactText} from './matchers/text.ts';
import {toProvideReactContext} from './matchers/context.ts';

@@ -28,4 +31,14 @@ // @see https://vitest.dev/guide/extending-matchers.html

toContainReactText(text: string): R;
toContainReactHTML(text: string): R;
toHaveReactDataProps(data: {[key: string]: string}): R;
}
export {matchers, domMatchers, type CustomDOMMatchers};
export const matchers = {
toHaveReactProps,
toContainReactComponent,
toContainReactComponentTimes,
toProvideReactContext,
toContainReactText,
toContainReactHTML,
toHaveReactDataProps,
};
import type {ComponentType} from 'react';
import type {MatcherState} from 'expect';
import type {MatcherState, MatcherUtils} from 'expect';
import {

@@ -18,2 +18,3 @@ matcherHint,

printType,
getObjectSubset,
} from './utilities.ts';

@@ -24,3 +25,3 @@

>(
this: MatcherState,
this: MatcherState & MatcherUtils,
node: Node<any, any>,

@@ -45,5 +46,3 @@ type: Type,

: foundByType.filter((element) =>
Object.keys(props).every((key) =>
Object.is((props as any)[key], (element.props as any)[key]),
),
this.equals(props, getObjectSubset(element.props, props)),
);

@@ -90,3 +89,3 @@

>(
this: MatcherState,
this: MatcherState & MatcherUtils,
node: Node<unknown>,

@@ -112,5 +111,3 @@ type: Type,

: foundByType.filter((element) =>
Object.keys(props).every((key) =>
Object.is((props as any)[key], (element.props as any)[key]),
),
this.equals(props, getObjectSubset(element.props, props)),
);

@@ -117,0 +114,0 @@

@@ -1,2 +0,2 @@

import type {MatcherState} from 'expect';
import type {MatcherState, MatcherUtils} from 'expect';
import {

@@ -48,3 +48,3 @@ matcherHint,

export function toHaveReactDataProps(
this: MatcherState,
this: MatcherState & MatcherUtils,
node: Node<unknown>,

@@ -51,0 +51,0 @@ data: {[key: string]: string},

@@ -1,2 +0,2 @@

import type {MatcherState} from 'expect';
import type {MatcherState, MatcherUtils} from 'expect';
import {

@@ -11,6 +11,6 @@ matcherHint,

import {assertIsNode, diffPropsForNode} from './utilities.ts';
import {assertIsNode, diffPropsForNode, getObjectSubset} from './utilities.ts';
export function toHaveReactProps<Props>(
this: MatcherState,
this: MatcherState & MatcherUtils,
node: Node<Props, any>,

@@ -34,5 +34,3 @@ props: Partial<Props>,

const pass = Object.keys(props).every((key) =>
Object.is((props as any)[key], (node.props as any)[key]),
);
const pass = this.equals(props, getObjectSubset(node.props, props));

@@ -39,0 +37,0 @@ const message = pass

@@ -133,3 +133,3 @@ import type {ComponentType} from 'react';

// Original from https://github.com/facebook/jest/blob/master/packages/expect/source/utils.ts#L107
function getObjectSubset(object: any, subset: any): any {
export function getObjectSubset(object: any, subset: any): any {
if (Array.isArray(object)) {

@@ -136,0 +136,0 @@ if (Array.isArray(subset) && subset.length === object.length) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc