| 18 | var _element; |
| 19 | |
| 20 | export class NavBarCommandTests { |
| 21 | |
| 22 | setUp = function () { |
| 23 | LiveUnit.LoggingCore.logComment("In setup"); |
| 24 | var newNode = document.createElement("div"); |
| 25 | newNode.id = "host"; |
| 26 | document.body.appendChild(newNode); |
| 27 | _element = newNode; |
| 28 | }; |
| 29 | |
| 30 | tearDown = function () { |
| 31 | LiveUnit.LoggingCore.logComment("In tearDown"); |
| 32 | if (_element) { |
| 33 | WinJS.Utilities.disposeSubTree(_element); |
| 34 | document.body.removeChild(_element); |
| 35 | _element = null; |
| 36 | } |
| 37 | }; |
| 38 | |
| 39 | testInstantiationMarkup = function (complete) { |
| 40 | var host = document.getElementById("host"); |
| 41 | var html = "<div id='navcmd' data-win-control='WinJS.UI.NavBarCommand' " + |
| 42 | "data-win-options='{ icon: WinJS.UI.AppBarIcon.add, splitButton: true }'" + |
| 43 | "></div>"; |
| 44 | |
| 45 | host.innerHTML = html; |
| 46 | |
| 47 | WinJS.UI.processAll(). |
| 48 | then(function () { |
| 49 | var navcmd = document.getElementById('navcmd').winControl; |
| 50 | LiveUnit.Assert.isTrue(WinJS.Utilities.hasClass(navcmd.element, "win-navbarcommand"), |
| 51 | "win-navbarcommand class not present"); |
| 52 | // Verify main button |
| 53 | var buttonEl = navcmd.element.querySelector(".win-navbarcommand-button"); |
| 54 | LiveUnit.Assert.isTrue(buttonEl, "win-navbarcommand-button class not present"); |
| 55 | // Verify split button |
| 56 | var splitButtonEl = navcmd.element.querySelector(".win-navbarcommand-splitbutton"); |
| 57 | LiveUnit.Assert.isTrue(splitButtonEl, "win-navbarcommand-splitbutton class not present"); |
| 58 | // Verify split and main button elements are not same |
| 59 | LiveUnit.Assert.isFalse(splitButtonEl === buttonEl); |
| 60 | // Verify icon |
| 61 | var iconEl = buttonEl.querySelector(".win-navbarcommand-icon"); |
| 62 | LiveUnit.Assert.isTrue(iconEl, "win-navbarcommand-icon class not present"); |
| 63 | // Verify label |
| 64 | var labelEl = buttonEl.querySelector(".win-navbarcommand-label"); |
| 65 | LiveUnit.Assert.isTrue(labelEl, "win-navbarcommand-label class not present"); |
| 66 | // Verify label and icon elements are not same |
| 67 | LiveUnit.Assert.isFalse(iconEl === labelEl); |
| 68 | }). |
| 69 | done(complete); |
| 70 | }; |
| 71 | |
| 72 | testLabel = function () { |
| 73 | var navbarCommand = new WinJS.UI.NavBarCommand(document.getElementById("host")); |
| 74 | LiveUnit.Assert.areEqual("", navbarCommand.element.textContent.trim()); |
| 75 | |
| 76 | navbarCommand.label = "abc"; |
| 77 | LiveUnit.Assert.areEqual("abc", navbarCommand.element.textContent.trim()); |
nothing calls this directly
no test coverage detected