#how to override MetaFunction parameter for testing

1 messages · Page 1 of 1 (latest)

slow furnace
#

I have a some complex data processing going on in my MetaFunction that I want to unit test:

export const meta: MetaFunction<{
    data: { pageContent: { title: string; seo: SEOFields } };
}> = ({ data }) => {
    // logic here
}

as you can see I'm trying to type the parameter of meta() so I can use a more simple type in my unit test:

        const data = {
            pageContent: {
                title: `Page Title`,
                seo: {
                    seo_title: `SEO Title`,
                    meta_description: `Meta Description`,
                    enable_search_indexing: true,
                    enable_search_following: true,
                    opengraph_metadata: {
                        title: `OG Title`,
                        description: `OG Description`,
                    },
                    twitter_metadata: {
                        title: `Twitter Title`,
                        description: `Twitter Description`,
                    },
                },
            },
        };
        const metaData = meta({ data });

however I get this type error:

#
Argument of type '{ data: { pageContent: { title: string; seo: { seo_title: string; meta_description: string; enable_search_indexing: boolean; enable_search_following: boolean; opengraph_metadata: { title: string; description: string; }; twitter_metadata: { ...; }; }; }; }; }' is not assignable to parameter of type '{ data: any; parentsData: {} & RouteData; params: Params; location: Location; }'.
  Type '{ data: { pageContent: { title: string; seo: { seo_title: string; meta_description: string; enable_search_indexing: boolean; enable_search_following: boolean; opengraph_metadata: { title: string; description: string; }; twitter_metadata: { ...; }; }; }; }; }' is missing the following properties from type '{ data: any; parentsData: {} & RouteData; params: Params; location: Location; }': parentsData, params, locationts(2345)
Argument of type '{ data: { pageContent: { title: string; seo: { seo_title: string; meta_description: string; enable_search_indexing: boolean; enable_search_following: boolean; opengraph_metadata: { title: string; description: string; }; twitter_metadata: { ...; }; }; }; };

which is saying that I'm missing some fields in { data } even though I thought I defined them when I typed the parameter in my previous file