Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion test/spec/LanguageManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,18 @@ define(function (require, exports, module) {
expect(LanguageManager.getLanguage(expected.id)).toBe(actual);
}

var i = 0,
expectedFileExtensions = expected.fileExtensions || [],
expectedFileExtensionsLength = expectedFileExtensions.length,
actualFileExtensions = actual.getFileExtensions();

expect(actual.getId()).toBe(expected.id);
expect(actual.getName()).toBe(expected.name);
expect(actual.getFileExtensions()).toEqual(expected.fileExtensions || []);

for (i; i < expectedFileExtensionsLength; i++) {
expect(actualFileExtensions).toContain(expectedFileExtensions[i]);
}
Copy link
Contributor

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.


expect(actual.getFileNames()).toEqual(expected.fileNames || []);

if (expected.blockComment) {
Expand Down