@codecademy/gamut-tests
7.1.07.1.1-alpha.3e37cd.0
~
Modified (3 files)
Index: package/dist/index.js
===================================================================
--- package/dist/index.js
+++ package/dist/index.js
@@ -25,7 +25,25 @@
});
return WithBoundaryComponent;
}
+/*
+ * component-test-setup decides whether `renderView`'s argument is required by
+ * asking, for each key of the props type, whether an arbitrary object would
+ * satisfy it. A `data-*` index signature (`DataAttributes` in
+ * @codecademy/gamut) answers no, since `unknown` isn't assignable to its value
+ * type, so the key gets treated as required and `renderView()` with no
+ * arguments stops compiling. Index signatures are never genuinely required, so
+ * drop them before that decision is made. Types only; no runtime effect.
+ */
+
+// mirrors component-test-setup's internal RequiredKeys, which it doesn't export
+
+/*
+ * component-test-setup doesn't export the type of what a render returns, so
+ * alias it here. Without an exported name, anything that re-exports a
+ * `renderView` fails declaration emit with TS4023.
+ */
+
// overArgs isn't fully typed yet for lack of curried generics, so we have to cast it...
export const setupRtl = overArgs(setupRtlBase, withMockGamutProvider);
\ No newline at end of file Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,11 +1,11 @@
{
"name": "@codecademy/gamut-tests",
"description": "Shared component test setup for Gamut applications",
- "version": "7.1.0",
+ "version": "7.1.1-alpha.3e37cd.0",
"author": "Codecademy Engineering <[email protected]>",
"dependencies": {
- "@codecademy/gamut-styles": "21.2.0",
+ "@codecademy/gamut-styles": "21.2.1-alpha.3e37cd.0",
"component-test-setup": "*",
"lodash": "^4.17.23"
},
"files": [ Index: package/dist/index.d.ts
===================================================================
--- package/dist/index.d.ts
+++ package/dist/index.d.ts
@@ -1,7 +1,22 @@
-import { setupRtl as setupRtlBase } from 'component-test-setup';
+import { FullProps, RemainingPropsAndTestOverrides, RenderRtl, SetupComponentType } from 'component-test-setup';
import * as React from 'react';
export declare const MockGamutProvider: React.FC<{
children?: React.ReactNode;
useLogicalProperties?: boolean;
}>;
-export declare const setupRtl: typeof setupRtlBase;
+type StripDataAttrs<T> = {
+ [K in keyof T as K extends `data-${string}` ? never : K]: T[K];
+};
+type RequiredKeys<T> = {
+ [K in keyof T]-?: Record<string, unknown> extends {
+ [P in K]: T[K];
+ } ? never : K;
+}[keyof T];
+type TestProps<Component extends SetupComponentType, BaseProps extends Partial<FullProps<Component>>> = RequiredKeys<StripDataAttrs<Omit<FullProps<Component>, keyof BaseProps>>> extends never ? [RemainingPropsAndTestOverrides<Component, BaseProps>?] : [RemainingPropsAndTestOverrides<Component, BaseProps>];
+export type GamutRenderRtlReturn<Component extends SetupComponentType, BaseProps extends Partial<FullProps<Component>>> = ReturnType<RenderRtl<Component, BaseProps>>;
+export type GamutRenderRtl<Component extends SetupComponentType, BaseProps extends Partial<FullProps<Component>>> = {
+ (...testProps: TestProps<Component, BaseProps>): GamutRenderRtlReturn<Component, BaseProps>;
+ options: (options: Parameters<RenderRtl<Component, BaseProps>['options']>[0]) => GamutRenderRtl<Component, BaseProps>;
+};
+export declare const setupRtl: <Component extends SetupComponentType, BaseProps extends Partial<FullProps<Component>> = {}>(Component: Component, baseProps?: BaseProps) => GamutRenderRtl<Component, BaseProps>;
+export {};