-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fixed language manager unit test. Issue #3957 #4106
Conversation
expect(actual.getFileExtensions()).toEqual(expected.fileExtensions || []); | ||
for (i = 0; i < actual.getFileExtensions.length; i++) { | ||
expect(expected.fileExtensions).toContain(actual.getFileExtensions()[i] || []); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code never goes in the loop because actual.getFileExtensions
is a reference to a function, it's not actually calling the function. It happens to have a length property that's 0. You can click on Show Developer Tools from the Jasmine Spec Runner Window, the click on the Source tab and set a breakpoint in the code to see what branches it takes and inspect the structure and value of object. This should be actual.getFileExtensions().length
instead.
Even better would be to only call actual.getFileExtensions()
once and store it in a local var.
Done with initial code review. |
Made sure the loop wasn't creating variables or calling functions over and over. Also fixed logic. Tested this under Win7 VM and everything appears to work. Dev tools say that the file extensions arrays are good too. |
} else { | ||
expectedFileExtensions = expected.fileExtensions; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code:
var expectedFileExtensions;
// Be sure that expectedFileExtensions is not undefined.
if (expected.fileExtensions === undefined) {
expectedFileExtensions = [];
} else {
expectedFileExtensions = expected.fileExtensions;
}
Can be replaced by this line of code:
var expectedFileExtensions = expected.fileExtensions || [];
When initializing expectedFileExtensions
, it's set to the first "truthy" element in the OR list. So, if expected.fileExtensions
is undefined (or null), then it's set to []
(an empty array). This code is actually better because it checks for both undefined and null;
This looks much better. One last comment. |
I shortened up the code as suggested. How does it look now? |
Thanks. Merging. |
Fixed language manager unit test. Issue #3957
This for (Issue #3957.
Okay. I am opening this new pull request to fix all of the merge issues of my last pull request (Issue #4097).
The code here takes all of the array of expected file extensions and makes sure it contains the actual file extensions, thus doing away with the problem of having to make the file extension arrays match.
I have tested this under my Windows VM and everything appears to work.