UnlyEd/next-typescript-api-zeit-boilerplate

View on GitHub
src/utils/testing/toContainObject.ts

Summary

Maintainability
A
0 mins
Test Coverage
// @ts-ignore
expect.extend({
  toContainObject(received, argument) {

    const pass = this.equals(received,
      expect.arrayContaining([
        expect.objectContaining(argument),
      ]),
    );

    if (pass) {
      return {
        message: () => (`expected ${this.utils.printReceived(received)} not to contain object ${this.utils.printExpected(argument)}`),
        pass: true,
      };
    } else {
      return {
        message: () => (`expected ${this.utils.printReceived(received)} to contain object ${this.utils.printExpected(argument)}`),
        pass: false,
      };
    }
  },
});