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

TL-19850 Finished log error logic around floors functionality #47

Merged
merged 2 commits into from
Apr 21, 2022

Conversation

patrickloughrey
Copy link

  • Added try catch functionality around price floors logic
  • Added corresponding test to make sure other currencies other than USD would be false

@@ -787,6 +787,28 @@ describe('triplelift adapter', function () {
size: '*'
})).to.be.true;
});
it('should not set bid floor if currency is not USD', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patrickloughrey The title is a little misleading from what's being tested.

We hardcode currency and size into how getFloor gets called.
image

So we'll never call getFloor (which is what calledWith is testing) with EUR or CAD. We could add that check though and add it under the existing 'should call getFloor with the correct parameters based on mediaType' test.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a test like this instead:

it('should catch error if getFloor throws error', function() {
      let logErrorSpy = sinon.spy(utils, 'logError');

      bidRequests[0].getFloor = () => {
        throw new Error('An exception!');
      };

      tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);

      expect(logErrorSpy.calledOnce).to.equal(true); <-- I've tested up to here and it works
      expect(logErrorSpy.message).to.eql('Triplelift: getFloor threw an error:') <--- This I've not tested but would be a nice to have
    });

Copy link
Author

@patrickloughrey patrickloughrey Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking back at this PR - good catch. I changed the tests to what you suggested. Currently unable to get the second expect statement to occur but working through that.

@nllerandi3lift nllerandi3lift merged commit da47d96 into master Apr 21, 2022
@nllerandi3lift nllerandi3lift deleted the TL-19850-floors-module-update branch April 21, 2022 13:53
@nllerandi3lift
Copy link

@patrickloughrey I've merged into our forked master. Feel free to PR into the main repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants