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

coveo-search-ui-tests

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coveo-search-ui-tests

Testing framework for the Coveo JavaScript Search Framework

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-29.41%
Maintainers
3
Weekly downloads
 
Created
Source

search-ui-tests

Testing framework for the Coveo JavaScript Search Framework

Usage

Include the compiled bin/js/CoveoJsSearchTests.js file in your test configuration.

TypeScript

You can import references from the component and then use them in your tests.

Example

In this example, MyCustomComponent is a simple custom component that registers a new event handler on the onBuildingQuery event to change the pipeline.

// MyCustomComponent.ts
import {
    Component,
    ComponentOptions,
    IComponentBindings,
    QueryEvents,
    IBuildingQueryEventArgs
} from "coveo-search-ui";

export class MyCustomComponent extends Component {
    static ID = "MyCustomComponent";

    static options: IMyCustomComponentOptions = {} 

    constructor(public element: HTMLElement, public options: IMyCustomComponentOptions, public bindings: IComponentBindings) {
        super(element, MyCustomComponent.ID, bindings);
        this.options = ComponentOptions.initComponentOptions(element, MyCustomComponent, options);

        this.bind.onRootElement(QueryEvents.buildingQuery, (args: IBuildingQueryEventArgs) => args.queryBuilder.pipeline = "a new pipeline");
    }
}

And here is the test to validate this behavior.

// MyCustomComponent.spec.ts
import { MyCustomComponent } from "./MyCustomComponent";
import { Mock, Simulate } from "coveo-search-ui-tests";

describe("MyCustomComponent", () => {
    let component: Mock.IBasicComponentSetup<MyCustomComponent>;

    beforeEach(() => {
        // Creates the component with all the set up required to run properly in a fake Coveo Search Interface environment.
        component = Mock.basicComponentSetup<MyCustomComponent>(MyCustomComponent);
    });

    afterEach(() => {
        component = null;
    });

    it("should change the pipeline in the query builder", () => {
        const expectedPipeline = "a new pipeline";

        // Simulate a query executed in the fake environment.
        const result = Simulate.query(component.env);

        expect(result.queryBuilder.pipeline).toBe(expectedPipeline);
    });
});

Modules

Mock

Allows to create mocks of components required for the framework.

Fake

Allows to create fake objects like results, events and fields.

Simulate

Allows to simulate some actions in the framework or in the browser.

Keywords

FAQs

Package last updated on 29 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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