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

Change not.toBeNull() to toBeTruthy() in unit tests #5492

Merged
merged 2 commits into from
Oct 18, 2013
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/extensions/default/CSSCodeHints/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ define(function (require, exports, module) {
function expectHints(provider, implicitChar) {
expect(provider.hasHints(testEditor, implicitChar)).toBe(true);
var hintsObj = provider.getHints();
expect(hintsObj).not.toBeNull();
expect(hintsObj).toBeTruthy();
return hintsObj.hints; // return just the array of hints
}

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/HTMLCodeHints/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ define(function (require, exports, module) {
function expectHints(provider) {
expect(provider.hasHints(testEditor, null)).toBe(true);
var hintsObj = provider.getHints();
expect(hintsObj).not.toBeNull();
expect(hintsObj).toBeTruthy();
return hintsObj.hints; // return just the array of hints
}

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/HtmlEntityCodeHints/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ define(function (require, exports, module) {
function expectHints(provider) {
expect(provider.hasHints(testEditorAndDoc.editor, null)).toBe(true);
var hintsObj = provider.getHints(null);
expect(hintsObj).not.toBeNull();
expect(hintsObj).toBeTruthy();
return hintsObj.hints; // return just the array of hints
}

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/InlineColorEditor/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ define(function (require, exports, module) {
makeColorEditor({line: 1, ch: 18});
runs(function () {
inline.colorEditor.setColorFromString("rgb(20, 20, 20)");
expect(inline.getCurrentRange()).not.toBeNull();
expect(inline.getCurrentRange()).toBeTruthy();
});
});

Expand Down
12 changes: 6 additions & 6 deletions src/extensions/default/JavaScriptCodeHints/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ define(function (require, exports, module) {
*/
function hintsAbsent(hintObj, absentHints) {
_waitForHints(hintObj, function (hintList) {
expect(hintList).not.toBeNull();
expect(hintList).toBeTruthy();
absentHints.forEach(function (absentHint) {
expect(_indexOf(hintList, absentHint)).toBe(-1);
});
Expand All @@ -203,7 +203,7 @@ define(function (require, exports, module) {
*/
function hintsPresent(hintObj, expectedHints) {
_waitForHints(hintObj, function (hintList) {
expect(hintList).not.toBeNull();
expect(hintList).toBeTruthy();
expectedHints.forEach(function (expectedHint) {
expect(_indexOf(hintList, expectedHint)).not.toBe(-1);
});
Expand All @@ -224,7 +224,7 @@ define(function (require, exports, module) {
currIndex;

_waitForHints(hintObj, function (hintList) {
expect(hintList).not.toBeNull();
expect(hintList).toBeTruthy();
expectedHints.forEach(function (expectedHint) {
currIndex = _indexOf(hintList, expectedHint);
expect(currIndex).toBeGreaterThan(prevIndex);
Expand All @@ -244,7 +244,7 @@ define(function (require, exports, module) {
*/
function hintsPresentExact(hintObj, expectedHints) {
_waitForHints(hintObj, function (hintList) {
expect(hintList).not.toBeNull();
expect(hintList).toBeTruthy();
expect(hintList.length).toBe(expectedHints.length);
expectedHints.forEach(function (expectedHint, index) {
expect(hintList[index].data("token").value).toBe(expectedHint);
Expand Down Expand Up @@ -282,9 +282,9 @@ define(function (require, exports, module) {
function selectHint(provider, hintObj, hintSelection) {
var hintList = expectHints(provider);
_waitForHints(hintObj, function (hintList) {
expect(hintList).not.toBeNull();
expect(hintList).toBeTruthy();
var index = findHint(hintList, hintSelection);
expect(hintList[index].data("token")).not.toBeNull();
expect(hintList[index].data("token")).toBeTruthy();
expect(provider.insertHint(hintList[index])).toBe(false);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/JavaScriptQuickEdit/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ define(function (require, exports, module) {
*/
function hintsPresentExact(hintObj, expectedHints) {
_waitForHints(hintObj, function (hintList) {
expect(hintList).not.toBeNull();
expect(hintList).toBeTruthy();
expect(hintList.length).toBe(expectedHints.length);
expectedHints.forEach(function (expectedHint, index) {
expect(hintList[index].data("token").value).toBe(expectedHint);
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/default/WebPlatformDocs/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ define(function (require, exports, module) {
runs(function () {
if (promise) {
if (expectInline) {
expect(widget).not.toBeNull();
expect(widget).toBeTruthy();
expect(widget.$htmlContent.find(".css-prop-summary h1").text()).toBe(expectedProperty);
} else {
expect(widget).toBeNull();
Expand Down Expand Up @@ -221,4 +221,4 @@ define(function (require, exports, module) {
});

});
});
});
4 changes: 2 additions & 2 deletions test/spec/CSSUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ define(function (require, exports, module) {

it("should find the first instance of the h2 selector", function () {
var selectors = CSSUtils._findAllMatchingSelectorsInText(this.fileContent, "h2");
expect(selectors).not.toBe(null);
expect(selectors).toBeTruthy();
expect(selectors.length).toBeGreaterThan(0);

expect(selectors[0]).not.toBe(null);
expect(selectors[0]).toBeTruthy();
expect(selectors[0].selectorStartLine).toBe(292);
expect(selectors[0].declListEndLine).toBe(301);
});
Expand Down
4 changes: 2 additions & 2 deletions test/spec/ExtensionInstallation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ define(function (require, exports, module) {

runs(function () {
expect(packageData.errors.length).toEqual(0);
expect(packageData.disabledReason).not.toBeNull();
expect(packageData.disabledReason).toBeTruthy();
expect(packageData.name).toEqual("incompatible-version");
expect(lastExtensionLoad).toEqual({});
NativeFileSystem.resolveNativeFileSystemPath(extensionsRoot + "/disabled/incompatible-version",
Expand Down Expand Up @@ -217,4 +217,4 @@ define(function (require, exports, module) {
});
});
});
});
});
2 changes: 1 addition & 1 deletion test/spec/HTMLInstrumentation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ define(function (require, exports, module) {
},
querySelectorAll: function (query) {
var match = bracketsIdQuery.exec(query);
expect(match).not.toBeNull();
expect(match).toBeTruthy();
if (!match) {
return [];
}
Expand Down
8 changes: 4 additions & 4 deletions test/spec/HTMLSimpleDOM-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ define(function (require, exports, module) {
if (expectedErrors) {
expect(root).toBeNull();
} else {
expect(root).not.toBeNull();
expect(root).toBeTruthy();
}

expect(errors).toEqual(expectedErrors);
Expand All @@ -62,12 +62,12 @@ define(function (require, exports, module) {
describe("Strict HTML parsing", function () {
it("should parse a document with balanced, void and self-closing tags", function () {
var root = build("<p><b>some</b>awesome text</p><p>and <img> another <br/> para</p>", true);
expect(root).not.toBeNull();
expect(root).toBeTruthy();
});

it("should parse a document with an implied-close tag followed by a tag that forces it to close", function () {
var result = build("<div><p>unclosed para<h1>heading that closes para</h1></div>", true);
expect(result).not.toBeNull();
expect(result).toBeTruthy();
expect(result.tag).toBe("div");
expect(result.children[0].tag).toBe("p");
expect(result.children[1].tag).toBe("h1");
Expand Down Expand Up @@ -185,4 +185,4 @@ define(function (require, exports, module) {
});
});
});
});
});
2 changes: 1 addition & 1 deletion test/spec/InstallExtensionDialog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ define(function (require, exports, module) {
}

it("should open the dialog", function () {
expect(fields.$dlg[0]).not.toBeNull();
expect(fields.$dlg[0]).toBeTruthy();
});

it("should have the install button disabled when dialog is first open due to empty url field", function () {
Expand Down
4 changes: 2 additions & 2 deletions test/spec/JSUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,10 @@ define(function (require, exports, module) {

it("should find the first instance of the pushStack function", function () {
var funcNames = JSUtils.findAllMatchingFunctionsInText(this.fileJsContent, "pushStack");
expect(funcNames).not.toBe(null);
expect(funcNames).toBeTruthy();
expect(funcNames.length).toBeGreaterThan(0);

expect(funcNames[0]).not.toBe(null);
expect(funcNames[0]).toBeTruthy();
expect(funcNames[0].lineStart).toBe(243);
expect(funcNames[0].lineEnd).toBe(267);
});
Expand Down
10 changes: 5 additions & 5 deletions test/spec/LanguageManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ define(function (require, exports, module) {
coffee = LanguageManager.getLanguage("coffeescript");

// check basic language support
expect(html).not.toBeNull();
expect(LanguageManager.getLanguage("css")).not.toBeNull();
expect(LanguageManager.getLanguage("javascript")).not.toBeNull();
expect(LanguageManager.getLanguage("json")).not.toBeNull();
expect(html).toBeTruthy();
expect(LanguageManager.getLanguage("css")).toBeTruthy();
expect(LanguageManager.getLanguage("javascript")).toBeTruthy();
expect(LanguageManager.getLanguage("json")).toBeTruthy();

// check html mode
var def = {
Expand Down Expand Up @@ -132,7 +132,7 @@ define(function (require, exports, module) {
it("should map identifiers to languages", function () {
var html = LanguageManager.getLanguage("html");

expect(html).not.toBe(null);
expect(html).toBeTruthy();
expect(LanguageManager.getLanguage("DoesNotExist")).toBe(undefined);
});

Expand Down
34 changes: 17 additions & 17 deletions test/spec/Menu-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ define(function (require, exports, module) {

var menuCountOriginal = $listItems.length;
var menu = Menus.addMenu("Custom1", "menu-unittest1");
expect(menu).not.toBeNull();
expect(menu).toBeTruthy();
expect(menu).toBeDefined();

$listItems = getTopMenus(); // refresh
Expand All @@ -272,7 +272,7 @@ define(function (require, exports, module) {

var menuCountOriginal = $listItems.length;
var menu = Menus.addMenu("Custom2", "menu-unittest2", Menus.FIRST);
expect(menu).not.toBeNull();
expect(menu).toBeTruthy();
expect(menu).toBeDefined();

$listItems = getTopMenus();
Expand All @@ -289,7 +289,7 @@ define(function (require, exports, module) {
var menuCountOriginal = $listItems.length;
var menu = Menus.addMenu("CustomFirst", "menu-unittest3-first", Menus.FIRST);
menu = Menus.addMenu("CustomAfter", "menu-unittest3-after", Menus.AFTER, "menu-unittest3-first");
expect(menu).not.toBeNull();
expect(menu).toBeTruthy();
expect(menu).toBeDefined();

$listItems = getTopMenus();
Expand All @@ -307,7 +307,7 @@ define(function (require, exports, module) {
var menuCountOriginal = $listItems.length;
var menu = Menus.addMenu("CustomLast", "menu-unittest3-last", Menus.LAST);
menu = Menus.addMenu("CustomBefore", "menu-unittest3-before", Menus.BEFORE, "menu-unittest3-last");
expect(menu).not.toBeNull();
expect(menu).toBeTruthy();
expect(menu).toBeDefined();

$listItems = getTopMenus();
Expand All @@ -324,7 +324,7 @@ define(function (require, exports, module) {

var menuCountOriginal = $listItems.length;
var menu = Menus.addMenu("Custom3", "menu-unittest4", Menus.AFTER, "NONEXISTANT");
expect(menu).not.toBeNull();
expect(menu).toBeTruthy();
expect(menu).toBeDefined();

$listItems = getTopMenus();
Expand All @@ -340,7 +340,7 @@ define(function (require, exports, module) {

var menuCountOriginal = $listItems.length;
var menu1 = Menus.addMenu("Custom5", "menu-unittest5");
expect(menu1).not.toBeNull();
expect(menu1).toBeTruthy();

var menu2 = null;

Expand Down Expand Up @@ -368,7 +368,7 @@ define(function (require, exports, module) {
// add new menu item to empty menu
CommandManager.register("Brackets Test Command Custom 0", "Menu-test.command00", function () {});
var menuItem = menu.addMenuItem("Menu-test.command00");
expect(menuItem).not.toBeNull();
expect(menuItem).toBeTruthy();
expect(menuItem).toBeDefined();

$listItems = testWindow.$(listSelector).children();
Expand All @@ -383,7 +383,7 @@ define(function (require, exports, module) {
// add new menu item in first position of menu
CommandManager.register("Brackets Test Command Custom 1", "Menu-test.command01", function () {});
menuItem = menu.addMenuItem("Menu-test.command01", "Ctrl-Alt-1", Menus.FIRST);
expect(menuItem).not.toBeNull();
expect(menuItem).toBeTruthy();
expect(menuItem).toBeDefined();

$listItems = testWindow.$(listSelector).children();
Expand All @@ -394,7 +394,7 @@ define(function (require, exports, module) {
// add new menu item in last position of menu
CommandManager.register("Brackets Test Command Custom 2", "Menu-test.command02", function () {});
menuItem = menu.addMenuItem("Menu-test.command02", Menus.LAST);
expect(menuItem).not.toBeNull();
expect(menuItem).toBeTruthy();
expect(menuItem).toBeDefined();

$listItems = testWindow.$(listSelector).children();
Expand All @@ -405,7 +405,7 @@ define(function (require, exports, module) {
// add new menu item in position after reference command
CommandManager.register("Brackets Test Command Custom 3", "Menu-test.command03", function () {});
menuItem = menu.addMenuItem("Menu-test.command03", "Ctrl-Alt-3", Menus.AFTER, "Menu-test.command01");
expect(menuItem).not.toBeNull();
expect(menuItem).toBeTruthy();
expect(menuItem).toBeDefined();

$listItems = testWindow.$(listSelector).children();
Expand All @@ -416,7 +416,7 @@ define(function (require, exports, module) {
// add new menu item in position before reference command
CommandManager.register("Brackets Test Command Custom 4", "Menu-test.command04", function () {});
menuItem = menu.addMenuItem("Menu-test.command04", "Ctrl-Alt-4", Menus.BEFORE, "Menu-test.command01");
expect(menuItem).not.toBeNull();
expect(menuItem).toBeTruthy();
expect(menuItem).toBeDefined();

$listItems = testWindow.$(listSelector).children();
Expand Down Expand Up @@ -499,7 +499,7 @@ define(function (require, exports, module) {
// reference command doesn't exist
CommandManager.register("Brackets Test Command Custom 21", "Menu-test.command21", function () {});
var menuItem = menu.addMenuItem("Menu-test.command21", "Ctrl-Alt-2", Menus.BEFORE, "NONEXISTANT");
expect(menuItem).not.toBeNull();
expect(menuItem).toBeTruthy();
expect(menuItem).toBeDefined();

var $listItems = testWindow.$(listSelector).children();
Expand All @@ -514,7 +514,7 @@ define(function (require, exports, module) {

CommandManager.register("Brackets Test Command Custom 23", "Menu-test.command23", function () {});
menuItem = menu.addMenuItem("Menu-test.command23", "Ctrl-Alt-3", Menus.BEFORE, "Menu-test.command22");
expect(menuItem).not.toBeNull();
expect(menuItem).toBeTruthy();
expect(menuItem).toBeDefined();

$listItems = testWindow.$(listSelector).children();
Expand All @@ -527,7 +527,7 @@ define(function (require, exports, module) {
CommandManager.register("Brackets Test Command Custom 25", "Menu-test.command25", function () {});

menuItem = menu.addMenuItem("Menu-test.command24", "Ctrl-Alt-1", Menus.BEFORE, "Menu-test.command25");
expect(menuItem).not.toBeNull();
expect(menuItem).toBeTruthy();
expect(menuItem).toBeDefined();

$listItems = testWindow.$(listSelector).children();
Expand Down Expand Up @@ -584,7 +584,7 @@ define(function (require, exports, module) {

// Re-use commands that are already registered
var menuItem = menu.addMenuItem(commandId);
expect(menuItem).not.toBeNull();
expect(menuItem).toBeTruthy();
expect(menuItem).toBeDefined();

expect(typeof (commandId)).toBe("string");
Expand All @@ -609,7 +609,7 @@ define(function (require, exports, module) {

// Re-use commands that are already registered
var menuItem = menu.addMenuItem(commandId);
expect(menuItem).not.toBeNull();
expect(menuItem).toBeTruthy();
expect(menuItem).toBeDefined();

$listItems = menuDOMChildren(menuItemId);
Expand Down Expand Up @@ -693,7 +693,7 @@ define(function (require, exports, module) {

// checked state
var cmd = CommandManager.register("Brackets Test Command Custom 40", "Menu-test.command40", function () {});
expect(cmd).not.toBeNull();
expect(cmd).toBeTruthy();
expect(cmd).toBeDefined();

var menu = Menus.addMenu("Synchronizing Menu", "menuitem-unittest4");
Expand Down
Loading