Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Unit test suite for InlineColorEditor #2174

Merged
merged 5 commits into from
Nov 21, 2012
Merged

Conversation

njx
Copy link

@njx njx commented Nov 21, 2012

@jasonsanjose

A few of these unit tests got checked in as part of an earlier pull request (and were reviewed by Peter F), but some of those got modified in this pull anyway, so it's probably worth just reviewing everything from scratch.

Note that these are all mocked tests in one form or another--the first set use a full InlineColorEditor and a mock editor/document (so the InlineColorEditor doesn't actually live in the mock editor); the later ones just test ColorEditor by itself (not inside an InlineColorEditor).

Let me know if you think I should build some more integration-y tests as well. I think these tests give pretty good overall coverage though.

@ghost ghost assigned jasonsanjose Nov 21, 2012
@njx
Copy link
Author

njx commented Nov 21, 2012

Oops, not quite ready yet...forgot to add the unit tests for the text field.

@njx
Copy link
Author

njx commented Nov 21, 2012

OK, should be ready for review now.

@jasonsanjose
Copy link
Member

Reviewing


// The hRatio1/vRatio1 are for setting up the pre-drag conditions. The expected value
// should be related to the hRatio2 or vRatio2.
function testDrag(itemMember, hRatio1, vRatio1, hRatio2, vRatio2, param, expectedValue, tolerance) {
Copy link
Author

Choose a reason for hiding this comment

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

One thing I was considering doing (since this is kind of "parameter hell") was changing these args to be an object (with fields named after the args), so the calls would be easier to read. The downside is that it makes the calls a lot more verbose, but maybe that's worth it for legibility. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Being verbose wouldn't hurt here, especially given the number of params.

Copy link
Author

Choose a reason for hiding this comment

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

Done. Hopefully it will be clearer now (though a lot longer :))

@jasonsanjose
Copy link
Member

Nicely done, especially without firing up a new window. I guess this stuff doesn't rely on ProjectManager, so that's a bonus. Initial review complete.

@njx
Copy link
Author

njx commented Nov 21, 2012

Changes pushed. I also added JSDoc comments to all the helper functions, since some of their args were just non-obvious enough to require some explanation.

@njx
Copy link
Author

njx commented Nov 21, 2012

Just added one last little refactoring cleanup I noticed.

@jasonsanjose
Copy link
Member

Looks good. Merging.

jasonsanjose added a commit that referenced this pull request Nov 21, 2012
Unit test suite for InlineColorEditor
@jasonsanjose jasonsanjose merged commit d75bf70 into master Nov 21, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants