Skip to content

test has false positive as it does not check if the processed message doesn't contain the deleted message #15

@CForrest97

Description

@CForrest97

In the test in file src/api/rest/tests/MQRestClient.unit.test.ts

describe("ZosmfRestClient tests", () => {
    it("should delete stack from any zosmf errors before presenting them to users", () => {
        const zosmfRestClient = new MQRestClient(new Session({hostname: "dummy"}));
        const shouldNotDeleteMessage = "This should not be deleted";
        const shouldDeleteMessage = "This should be deleted";
        const error: IImperativeError = {
            msg: "hello",
            causeErrors: JSON.stringify({
                stack: shouldDeleteMessage,
                shouldNotDelete: shouldNotDeleteMessage
            })
        };
        const processedError = ((zosmfRestClient as any).processError(error));
        expect(processedError.msg).toContain(shouldNotDeleteMessage);
        expect(processedError.msg.indexOf()).toEqual(-1);

    });
});

the line expect(processedError.msg.indexOf()).toEqual(-1); doesnt actually check the message has been deleted, it just happens that the default behaviour is to return -1

potential fix: expect(processedError.msg.indexOf(shouldDeleteMessage)).toEqual(-1);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Low Priority

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions