New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@quilted/react-testing

Package Overview
Dependencies
Maintainers
1
Versions
164
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.6.0 to 0.6.1

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.6.1
### Patch Changes
- [`4df2d665`](https://github.com/lemonmade/quilt/commit/4df2d665ae22201afa86e7a5f214f73f5428ea4e) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix React testing exports
## 0.6.0

@@ -4,0 +10,0 @@

{
"name": "@quilted/react-testing",
"type": "module",
"version": "0.6.0",
"version": "0.6.1",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

@@ -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

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

'received',
)} value must be an @shopify/react-testing Root or Element object`,
)} value must be an @quilted/react-testing Root or Element object`,
`Received ${receivedColor(

@@ -41,3 +41,3 @@ 'null',

'received',
)} value must be an @shopify/react-testing Root or Element object`,
)} value must be an @quilted/react-testing Root or Element object`,
`Received an ${receivedColor(

@@ -56,3 +56,3 @@ 'array of Root or Element objects',

'received',
)} value must be an @shopify/react-testing Root or Element object`,
)} value must be an @quilted/react-testing Root or Element object`,
printWithType('Received', node, printReceived),

@@ -136,3 +136,3 @@ ),

// 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)) {

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

{
"extends": "@quilted/typescript/project.json",
"extends": "@quilted/craft/typescript/project.json",
"compilerOptions": {

@@ -4,0 +4,0 @@ "rootDir": "source",

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