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

Commit

Permalink
adds a test for ProjectManager.shouldShow.
Browse files Browse the repository at this point in the history
Also corrects a bug with pull request #2366
  • Loading branch information
dangoor committed Dec 17, 2012
1 parent 46efcdb commit 8a1c363
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,17 @@ define(function (require, exports, module) {
return result.promise();
}

/** @param {Entry} entry File or directory to filter */
/**
* Returns false for files and directories that are not commonly useful to display.
*
* @param {Entry} entry File or directory to filter
* @return boolean true if the file should be displayed
*/
function shouldShow(entry) {
if ([".git", ".gitignore", ".gitmodules", ".svn", ".DS_Store", "Thumbs.db"].indexOf(entry.name) > -1) {
return false;
}
var extension = entry.name.split('.').slice(-1);
var extension = entry.name.split('.').pop();
if (["pyc"].indexOf(extension) > -1) {
return false;
}
Expand Down
14 changes: 14 additions & 0 deletions test/spec/ProjectManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@ define(function (require, exports, module) {
}
});
});

describe("File Display", function () {
it("should not show useless directory entries", function () {
var shouldShow = ProjectManager.shouldShow;
var makeEntry = function (name) {
return { name: name };
};

expect(shouldShow(makeEntry(".gitmodules"))).toBe(false);
expect(shouldShow(makeEntry("foobar"))).toBe(true);
expect(shouldShow(makeEntry("pyc.py"))).toBe(true);
expect(shouldShow(makeEntry("module.pyc"))).toBe(false);
});
});

});
});

0 comments on commit 8a1c363

Please sign in to comment.