Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New e2e function, TestValidator.search() #280

Closed
samchon opened this issue Mar 15, 2023 · 0 comments
Closed

New e2e function, TestValidator.search() #280

samchon opened this issue Mar 15, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@samchon
Copy link
Owner

samchon commented Mar 15, 2023

Make a validation function for search option provided APIs.

export namespace TestValidator {
    /**
     * Valiate search options.
     *
     * Test a pagination API supporting search options.
     *
     * @param title Title of error message when searching is invalid
     * @returns Currying function
     *
     * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_search.ts
     */
    export const search =
        (title: string) =>
        /**
         * @param getter A pagination API function to be called
         */
        <Entity extends IEntity<any>, Request>(
            getter: (input: Request) => Promise<Entity[]>,
        ) =>
        /**
         * @param total Total entity records for comparison
         * @param sampleCount Sampling count. Default is 1
         */
        (total: Entity[], sampleCount: number = 1) =>
        /**
         * @param props Search properties
         */
        async <Values extends any[]>(
            props: ISearchProps<Entity, Values, Request>,
        ): Promise<void>;

    export interface ISearchProps<
        Entity extends IEntity<any>,
        Values extends any[],
        Request,
    > {
        fields: string[];
        values(entity: Entity): Values;
        filter(entity: Entity, values: Values): boolean;
        request(values: Values): Request;
    }
}
@samchon samchon added the enhancement New feature or request label Mar 15, 2023
@samchon samchon self-assigned this Mar 15, 2023
samchon added a commit that referenced this issue Mar 15, 2023
Close #280 - `TestValidator.search()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant