How to use has method in Playwright Internal

Best JavaScript code snippet using playwright-internal

test_Signal.js

Source:test_Signal.js Github

copy

Full Screen

1if (typeof(dojo) != 'undefined') { dojo.require('MochiKit.Signal'); }2if (typeof(JSAN) != 'undefined') { JSAN.use('MochiKit.Signal'); }3if (typeof(tests) == 'undefined') { tests = {}; }4tests.test_Signal = function (t) {5 6 var submit = MochiKit.DOM.getElement('submit');7 var ident = null;8 var i = 0;9 var aFunction = function() {10 t.ok(this === submit, "aFunction should have 'this' as submit");11 i++;12 if (typeof(this.someVar) != 'undefined') {13 i += this.someVar;14 }15 };16 17 var aObject = {};18 aObject.aMethod = function() {19 t.ok(this === aObject, "aMethod should have 'this' as aObject");20 i++;21 };22 ident = connect('submit', 'onclick', aFunction);23 MochiKit.DOM.getElement('submit').click();24 t.is(i, 1, 'HTML onclick event can be connected to a function');25 disconnect(ident);26 MochiKit.DOM.getElement('submit').click();27 t.is(i, 1, 'HTML onclick can be disconnected from a function');28 var submit = MochiKit.DOM.getElement('submit');29 ident = connect(submit, 'onclick', aFunction);30 submit.click();31 t.is(i, 2, 'Checking that a DOM element can be connected to a function');32 disconnect(ident);33 submit.click();34 t.is(i, 2, '...and then disconnected'); 35 36 if (MochiKit.DOM.getElement('submit').fireEvent || 37 (document.createEvent && 38 typeof(document.createEvent('MouseEvents').initMouseEvent) == 'function')) {39 40 /* 41 42 Adapted from: 43 http://www.devdaily.com/java/jwarehouse/jforum/tests/selenium/javascript/htmlutils.js.shtml44 License: Apache45 Copyright: Copyright 2004 ThoughtWorks, Inc46 47 */48 var triggerMouseEvent = function(element, eventType, canBubble) {49 element = MochiKit.DOM.getElement(element);50 canBubble = (typeof(canBubble) == 'undefined') ? true : canBubble;51 if (element.fireEvent) {52 var newEvt = document.createEventObject();53 newEvt.clientX = 1;54 newEvt.clientY = 1;55 newEvt.button = 1;56 element.fireEvent('on' + eventType, newEvt);57 } else if (document.createEvent && (typeof(document.createEvent('MouseEvents').initMouseEvent) == 'function')) {58 var evt = document.createEvent('MouseEvents');59 evt.initMouseEvent(eventType, canBubble, true, // event, bubbles, cancelable60 document.defaultView, 1, // view, # of clicks61 1, 0, 0, 0, // screenX, screenY, clientX, clientY62 false, false, false, false, // ctrlKey, altKey, shiftKey, metaKey63 0, null); // buttonCode, relatedTarget64 element.dispatchEvent(evt);65 }66 };67 var eventTest = function(e) {68 i++;69 t.ok((typeof(e.event()) === 'object'), 'checking that event() is an object');70 t.ok((typeof(e.type()) === 'string'), 'checking that type() is a string');71 t.ok((e.target() === MochiKit.DOM.getElement('submit')), 'checking that target is "submit"');72 t.ok((typeof(e.modifier()) === 'object'), 'checking that modifier() is an object');73 t.ok(e.modifier().alt === false, 'checking that modifier().alt is defined, but false');74 t.ok(e.modifier().ctrl === false, 'checking that modifier().ctrl is defined, but false');75 t.ok(e.modifier().meta === false, 'checking that modifier().meta is defined, but false');76 t.ok(e.modifier().shift === false, 'checking that modifier().shift is defined, but false');77 t.ok((typeof(e.mouse()) === 'object'), 'checking that mouse() is an object');78 t.ok((typeof(e.mouse().button) === 'object'), 'checking that mouse().button is an object');79 t.ok(e.mouse().button.left === true, 'checking that mouse().button.left is true');80 t.ok(e.mouse().button.middle === false, 'checking that mouse().button.middle is false');81 t.ok(e.mouse().button.right === false, 'checking that mouse().button.right is false');82 t.ok((typeof(e.mouse().page) === 'object'), 'checking that mouse().page is an object');83 t.ok((typeof(e.mouse().page.x) === 'number'), 'checking that mouse().page.x is a number');84 t.ok((typeof(e.mouse().page.y) === 'number'), 'checking that mouse().page.y is a number');85 t.ok((typeof(e.mouse().client) === 'object'), 'checking that mouse().client is an object');86 t.ok((typeof(e.mouse().client.x) === 'number'), 'checking that mouse().client.x is a number');87 t.ok((typeof(e.mouse().client.y) === 'number'), 'checking that mouse().client.y is a number');88 /* these should not be defined */89 t.ok((typeof(e.relatedTarget()) === 'undefined'), 'checking that relatedTarget() is undefined');90 t.ok((typeof(e.key()) === 'undefined'), 'checking that key() is undefined');91 };92 93 ident = connect('submit', 'onmousedown', eventTest);94 triggerMouseEvent('submit', 'mousedown', false);95 t.is(i, 3, 'Connecting an event to an HTML object and firing a synthetic event');96 disconnect(ident);97 triggerMouseEvent('submit', 'mousedown', false);98 t.is(i, 3, 'Disconnecting an event to an HTML object and firing a synthetic event');99 100 } 101 // non-DOM tests102 var hasNoSignals = {};103 104 var hasSignals = {someVar: 1};105 var i = 0;106 107 var aFunction = function() {108 i++;109 if (typeof(this.someVar) != 'undefined') {110 i += this.someVar;111 }112 };113 114 var bFunction = function(someArg, someOtherArg) {115 i += someArg + someOtherArg;116 };117 118 var aObject = {};119 aObject.aMethod = function() {120 i++;121 };122 123 aObject.bMethod = function() {124 i++;125 };126 127 var bObject = {};128 bObject.bMethod = function() {129 i++;130 };131 ident = connect(hasSignals, 'signalOne', aFunction);132 signal(hasSignals, 'signalOne');133 t.is(i, 2, 'Connecting function');134 i = 0;135 disconnect(ident);136 signal(hasSignals, 'signalOne');137 t.is(i, 0, 'New style disconnecting function');138 i = 0;139 ident = connect(hasSignals, 'signalOne', bFunction);140 signal(hasSignals, 'signalOne', 1, 2);141 t.is(i, 3, 'Connecting function');142 i = 0;143 disconnect(ident);144 signal(hasSignals, 'signalOne', 1, 2);145 t.is(i, 0, 'New style disconnecting function');146 i = 0;147 connect(hasSignals, 'signalOne', aFunction);148 signal(hasSignals, 'signalOne');149 t.is(i, 2, 'Connecting function');150 i = 0;151 disconnect(hasSignals, 'signalOne', aFunction);152 signal(hasSignals, 'signalOne');153 t.is(i, 0, 'Old style disconnecting function');154 i = 0;155 ident = connect(hasSignals, 'signalOne', aObject, aObject.aMethod);156 signal(hasSignals, 'signalOne');157 t.is(i, 1, 'Connecting obj-function');158 i = 0;159 disconnect(ident);160 signal(hasSignals, 'signalOne');161 t.is(i, 0, 'New style disconnecting obj-function');162 i = 0;163 connect(hasSignals, 'signalOne', aObject, aObject.aMethod);164 signal(hasSignals, 'signalOne');165 t.is(i, 1, 'Connecting obj-function');166 i = 0;167 disconnect(hasSignals, 'signalOne', aObject, aObject.aMethod);168 signal(hasSignals, 'signalOne');169 t.is(i, 0, 'Disconnecting obj-function');170 i = 0;171 ident = connect(hasSignals, 'signalTwo', aObject, 'aMethod');172 signal(hasSignals, 'signalTwo');173 t.is(i, 1, 'Connecting obj-string');174 i = 0;175 disconnect(ident);176 signal(hasSignals, 'signalTwo');177 t.is(i, 0, 'New style disconnecting obj-string');178 i = 0;179 connect(hasSignals, 'signalTwo', aObject, 'aMethod');180 signal(hasSignals, 'signalTwo');181 t.is(i, 1, 'Connecting obj-string');182 i = 0;183 disconnect(hasSignals, 'signalTwo', aObject, 'aMethod');184 signal(hasSignals, 'signalTwo');185 t.is(i, 0, 'Old style disconnecting obj-string');186 i = 0;187 var shouldRaise = function() { return undefined.attr; };188 try {189 connect(hasSignals, 'signalOne', shouldRaise);190 signal(hasSignals, 'signalOne');191 t.ok(false, 'An exception was not raised');192 } catch (e) {193 t.ok(true, 'An exception was raised');194 }195 disconnect(hasSignals, 'signalOne', shouldRaise);196 t.is(i, 0, 'Exception raised, signal should not have fired');197 i = 0;198 199 connect(hasSignals, 'signalOne', aObject, 'aMethod');200 connect(hasSignals, 'signalOne', aObject, 'bMethod');201 signal(hasSignals, 'signalOne');202 t.is(i, 2, 'Connecting one signal to two slots in one object');203 i = 0;204 205 disconnect(hasSignals, 'signalOne', aObject, 'aMethod');206 disconnect(hasSignals, 'signalOne', aObject, 'bMethod');207 signal(hasSignals, 'signalOne');208 t.is(i, 0, 'Disconnecting one signal from two slots in one object');209 i = 0;210 connect(hasSignals, 'signalOne', aObject, 'aMethod');211 connect(hasSignals, 'signalOne', bObject, 'bMethod');212 signal(hasSignals, 'signalOne');213 t.is(i, 2, 'Connecting one signal to two slots in two objects');214 i = 0;215 disconnect(hasSignals, 'signalOne', aObject, 'aMethod');216 disconnect(hasSignals, 'signalOne', bObject, 'bMethod');217 signal(hasSignals, 'signalOne');218 t.is(i, 0, 'Disconnecting one signal from two slots in two objects');219 i = 0;220 221 try {222 connect(nothing, 'signalOne', aObject, 'aMethod');223 signal(nothing, 'signalOne');224 t.ok(false, 'An exception was not raised when connecting undefined');225 } catch (e) {226 t.ok(true, 'An exception was raised when connecting undefined');227 }228 try {229 disconnect(nothing, 'signalOne', aObject, 'aMethod');230 t.ok(false, 'An exception was not raised when disconnecting undefined');231 } catch (e) {232 t.ok(true, 'An exception was raised when disconnecting undefined');233 }234 235 236 try {237 connect(hasSignals, 'signalOne', nothing);238 signal(hasSignals, 'signalOne');239 t.ok(false, 'An exception was not raised when connecting an undefined function');240 } catch (e) {241 t.ok(true, 'An exception was raised when connecting an undefined function');242 }243 try {244 disconnect(hasSignals, 'signalOne', nothing);245 t.ok(false, 'An exception was not raised when disconnecting an undefined function');246 } catch (e) {247 t.ok(true, 'An exception was raised when disconnecting an undefined function');248 }249 250 251 try {252 connect(hasSignals, 'signalOne', aObject, aObject.nothing);253 signal(hasSignals, 'signalOne');254 t.ok(false, 'An exception was not raised when connecting an undefined method');255 } catch (e) {256 t.ok(true, 'An exception was raised when connecting an undefined method');257 }258 259 try {260 connect(hasSignals, 'signalOne', aObject, 'nothing');261 signal(hasSignals, 'signalOne');262 t.ok(false, 'An exception was not raised when connecting an undefined method (as string)');263 } catch (e) {264 t.ok(true, 'An exception was raised when connecting an undefined method (as string)');265 }266 t.is(i, 0, 'Signals should not have fired');267 connect(hasSignals, 'signalOne', aFunction);268 connect(hasSignals, 'signalOne', aObject, 'aMethod');269 disconnectAll(hasSignals, 'signalOne');270 signal(hasSignals, 'signalOne');271 t.is(i, 0, 'disconnectAll works with single explicit signal');272 i = 0;273 connect(hasSignals, 'signalOne', aFunction);274 connect(hasSignals, 'signalOne', aObject, 'aMethod');275 connect(hasSignals, 'signalTwo', aFunction);276 connect(hasSignals, 'signalTwo', aObject, 'aMethod');277 disconnectAll(hasSignals, 'signalOne');278 signal(hasSignals, 'signalOne');279 t.is(i, 0, 'disconnectAll works with single explicit signal');280 signal(hasSignals, 'signalTwo');281 t.is(i, 3, 'disconnectAll does not disconnect unrelated signals');282 i = 0;283 connect(hasSignals, 'signalOne', aFunction);284 connect(hasSignals, 'signalOne', aObject, 'aMethod');285 connect(hasSignals, 'signalTwo', aFunction);286 connect(hasSignals, 'signalTwo', aObject, 'aMethod');287 disconnectAll(hasSignals, 'signalOne', 'signalTwo');288 signal(hasSignals, 'signalOne');289 signal(hasSignals, 'signalTwo');290 t.is(i, 0, 'disconnectAll works with two explicit signals');291 i = 0;292 connect(hasSignals, 'signalOne', aFunction);293 connect(hasSignals, 'signalOne', aObject, 'aMethod');294 connect(hasSignals, 'signalTwo', aFunction);295 connect(hasSignals, 'signalTwo', aObject, 'aMethod');296 disconnectAll(hasSignals, ['signalOne', 'signalTwo']);297 signal(hasSignals, 'signalOne');298 signal(hasSignals, 'signalTwo');299 t.is(i, 0, 'disconnectAll works with two explicit signals as a list');300 i = 0;301 connect(hasSignals, 'signalOne', aFunction);302 connect(hasSignals, 'signalOne', aObject, 'aMethod');303 connect(hasSignals, 'signalTwo', aFunction);304 connect(hasSignals, 'signalTwo', aObject, 'aMethod');305 disconnectAll(hasSignals);306 signal(hasSignals, 'signalOne');307 signal(hasSignals, 'signalTwo');308 t.is(i, 0, 'disconnectAll works with implicit signals');309 i = 0;310 311 var toggle = function() {312 disconnectAll(hasSignals, 'signalOne');313 connect(hasSignals, 'signalOne', aFunction);314 i++;315 };316 317 connect(hasSignals, 'signalOne', aFunction);318 connect(hasSignals, 'signalTwo', function() { i++; });319 connect(hasSignals, 'signalTwo', toggle);320 connect(hasSignals, 'signalTwo', function() { i++; }); // #147321 connect(hasSignals, 'signalTwo', function() { i++; });322 signal(hasSignals, 'signalTwo');323 t.is(i, 4, 'disconnectAll fired in a signal loop works');324 i = 0;325 disconnectAll('signalOne');326 disconnectAll('signalTwo');327 var testfunc = function () { arguments.callee.count++; };328 testfunc.count = 0;329 var testObj = {330 methOne: function () { this.countOne++; }, countOne: 0,331 methTwo: function () { this.countTwo++; }, countTwo: 0332 };333 connect(hasSignals, 'signalOne', testfunc);334 connect(hasSignals, 'signalTwo', testfunc);335 signal(hasSignals, 'signalOne');336 signal(hasSignals, 'signalTwo');337 t.is(testfunc.count, 2, 'disconnectAllTo func precondition');338 disconnectAllTo(testfunc);339 signal(hasSignals, 'signalOne');340 signal(hasSignals, 'signalTwo');341 t.is(testfunc.count, 2, 'disconnectAllTo func');342 connect(hasSignals, 'signalOne', testObj, 'methOne');343 connect(hasSignals, 'signalTwo', testObj, 'methTwo');344 signal(hasSignals, 'signalOne');345 signal(hasSignals, 'signalTwo');346 t.is(testObj.countOne, 1, 'disconnectAllTo obj precondition');347 t.is(testObj.countTwo, 1, 'disconnectAllTo obj precondition');348 disconnectAllTo(testObj);349 signal(hasSignals, 'signalOne');350 signal(hasSignals, 'signalTwo');351 t.is(testObj.countOne, 1, 'disconnectAllTo obj');352 t.is(testObj.countTwo, 1, 'disconnectAllTo obj');353 testObj.countOne = testObj.countTwo = 0;354 connect(hasSignals, 'signalOne', testObj, 'methOne');355 connect(hasSignals, 'signalTwo', testObj, 'methTwo');356 disconnectAllTo(testObj, 'methOne');357 signal(hasSignals, 'signalOne');358 signal(hasSignals, 'signalTwo');359 t.is(testObj.countOne, 0, 'disconnectAllTo obj+str');360 t.is(testObj.countTwo, 1, 'disconnectAllTo obj+str');361 362 has__Connect = {363 count: 0,364 __connect__: function (ident) {365 this.count += arguments.length;366 disconnect(ident);367 }368 };369 connect(has__Connect, 'signalOne', aFunction);370 t.is(has__Connect.count, 3, '__connect__ is called when it exists');371 signal(has__Connect, 'signalOne');372 t.is(has__Connect.count, 3, '__connect__ can disconnect the signal');373 var events = {};374 var test_ident = connect(events, "test", function() {375 var fail_ident = connect(events, "fail", function () {376 events.failed = true;377 });378 disconnect(fail_ident);379 signal(events, "fail");380 });381 signal(events, "test");382 t.is(events.failed, undefined, 'disconnected slots do not fire');383 var sink = {f: function (ev) { this.ev = ev; }};384 var src = {};385 bindMethods(sink);386 connect(src, 'signal', sink.f);387 signal(src, 'signal', 'worked');388 t.is(sink.ev, 'worked', 'custom signal does not re-bind methods');389 ...

Full Screen

Full Screen

header.js

Source:header.js Github

copy

Full Screen

1/*2 backgrid3 http://github.com/wyuenho/backgrid4 Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors5 Licensed under the MIT license.6*/7describe("A HeaderCell", function () {8 var col;9 var cell;10 beforeEach(function () {11 col = new Backbone.Collection([{id: 2}, {id: 1}, {id: 3}]);12 cell = new Backgrid.HeaderCell({13 column: {14 name: "id",15 cell: "integer"16 },17 collection: col18 });19 cell.render();20 });21 it("renders a table header cell with the label text and an optional anchor with sort-caret", function () {22 expect(cell.el.tagName).toBe("TH");23 expect(cell.$el.find("a").text()).toBe("id");24 expect(cell.$el.find(".sort-caret").length).toBe(1);25 cell.column.set("sortable", false);26 cell.render();27 expect(cell.el.tagName).toBe("TH");28 expect(cell.$el.text()).toBe("id");29 expect(cell.$el.find(".sort-caret").length).toBe(0);30 });31 it("adds an editable, sortable and a renderable class to the cell if these column attributes are true", function () {32 var column = {33 name: "title",34 cell: "string"35 };36 cell = new Backgrid.HeaderCell({37 column: column,38 collection: col39 });40 expect(cell.$el.hasClass("editable")).toBe(true);41 expect(cell.$el.hasClass("sortable")).toBe(true);42 expect(cell.$el.hasClass("renderable")).toBe(true);43 cell.column.set("editable", false);44 expect(cell.$el.hasClass("editable")).toBe(false);45 cell.column.set("sortable", false);46 expect(cell.$el.hasClass("sortable")).toBe(false);47 cell.column.set("renderable", false);48 expect(cell.$el.hasClass("renderable")).toBe(false);49 var TrueCol = Backgrid.Column.extend({50 mySortable: function () { return true; },51 myRenderable: function () { return true; },52 myEditable: function () { return true; }53 });54 var FalseCol = Backgrid.Column.extend({55 mySortable: function () { return false; },56 myRenderable: function () { return false; },57 myEditable: function () { return false; }58 });59 column = new TrueCol({60 name: "title",61 cell: "string",62 sortable: "mySortable",63 renderable: "myRenderable",64 editable: "myEditable"65 });66 cell = new Backgrid.HeaderCell({67 column: column,68 collection: col69 });70 expect(cell.$el.hasClass("editable")).toBe(true);71 expect(cell.$el.hasClass("sortable")).toBe(true);72 expect(cell.$el.hasClass("renderable")).toBe(true);73 column = new FalseCol({74 name: "title",75 cell: "string",76 sortable: "mySortable",77 renderable: "myRenderable",78 editable: "myEditable"79 });80 cell = new Backgrid.HeaderCell({81 column: column,82 collection: col83 });84 expect(cell.$el.hasClass("editable")).toBe(false);85 expect(cell.$el.hasClass("sortable")).toBe(false);86 expect(cell.$el.hasClass("renderable")).toBe(false);87 column = new Backgrid.Column({88 name: "title",89 cell: "string",90 sortable: function () { return true; },91 editable: function () { return true; },92 renderable: function () { return true; }93 });94 cell = new Backgrid.HeaderCell({95 column: column,96 collection: col97 });98 expect(cell.$el.hasClass("editable")).toBe(true);99 expect(cell.$el.hasClass("sortable")).toBe(true);100 expect(cell.$el.hasClass("renderable")).toBe(true);101 });102 it("will rerender with the column name and/or label changes", function () {103 expect(cell.$el.find("a").text(), "id");104 expect(cell.$el.hasClass("id"), true);105 cell.column.set("name", "name");106 expect(cell.$el.find("name"), true);107 expect(cell.$el.hasClass("name"), true);108 cell.column.set("label", "Name");109 expect(cell.$el.find("a").text(), "Name");110 expect(cell.$el.hasClass("Name"), true);111 });112 it("will put a class indicating the sorting direction if `direction` is set in the column", function () {113 cell = new Backgrid.HeaderCell({114 column: {115 name: "id",116 cell: "integer",117 direction: "descending"118 },119 collection: col120 });121 cell.render();122 expect(cell.el.tagName).toBe("TH");123 expect(cell.$el.find("a").text()).toBe("id");124 expect(cell.$el.find(".sort-caret").length).toBe(1);125 expect(cell.$el.hasClass("descending")).toBe(true);126 });127 it("triggers `backgrid:sort` with the column and direction set to 'ascending' if the column's direction is not set", function () {128 var column, direction;129 cell.collection.on("backgrid:sort", function (col, dir) { column = col; direction = dir; });130 cell.$el.find("a").click();131 expect(column).toBe(cell.column);132 expect(direction).toBe("ascending");133 });134 it("triggers `backgrid:sort` with the column and direction set to 'descending' if the column's direction is set to 'ascending'", function () {135 var column, direction;136 cell.collection.on("backgrid:sort", function (col, dir) { column = col; direction = dir; });137 cell.column.set("direction", "ascending");138 cell.$el.find("a").click();139 expect(column).toBe(cell.column);140 expect(direction).toBe("descending");141 });142 it("triggers `backgrid:sort` with the column and direction set to `null` if the column's direction is set to 'descending'", function () {143 var column, direction;144 cell.collection.on("backgrid:sort", function (col, dir) { column = col; direction = dir; });145 cell.column.set("direction", "descending");146 cell.$el.find("a").click();147 expect(column).toBe(cell.column);148 expect(direction).toBeNull();149 });150 it("will set the column to the correct direction when `change:direction` is triggered from the column", function () {151 cell.column.set("direction", "ascending");152 expect(cell.$el.hasClass("ascending")).toBe(true);153 cell.column.set("direction", "descending");154 expect(cell.$el.hasClass("descending")).toBe(true);155 cell.column.set("direction", null);156 expect(cell.$el.hasClass("ascending")).toBe(false);157 expect(cell.$el.hasClass("descending")).toBe(false);158 });159 it("will remove its direction CSS class if `sort` is triggered from the collection or pageableCollection#fullCollection", function () {160 cell.column.set("direction", "ascending");161 cell.collection.comparator = "id";162 cell.collection.sort();163 expect(cell.$el.hasClass("ascending")).toBe(false);164 expect(cell.$el.hasClass("descending")).toBe(false);165 col = new Backbone.PageableCollection(col.toJSON(), {166 mode: "client"167 });168 col.setSorting("id", 1);169 cell = new Backgrid.HeaderCell({170 column: {171 name: "id",172 cell: "integer"173 },174 collection: col175 });176 cell.column.set("direction", "ascending");177 cell.collection.fullCollection.comparator = "id";178 cell.collection.fullCollection.sort();179 expect(cell.$el.hasClass("ascending")).toBe(false);180 expect(cell.$el.hasClass("descending")).toBe(false);181 });182 it("with `sortType` set to `toggle`, triggers `backgrid:sort` with the column and direction set to 'ascending' if the column's direction is not set", function () {183 var column, direction;184 cell.column.set("sortType", "toggle");185 cell.collection.on("backgrid:sort", function (col, dir) { column = col; direction = dir; });186 cell.$el.find("a").click();187 expect(column).toBe(cell.column);188 expect(direction).toBe("ascending");189 });190 it("with `sortType` set to `toggle`, triggers `backgrid:sort` with the column and direction set to 'descending' if the column's direction is set to 'ascending'", function () {191 var column, direction;192 cell.column.set("sortType", "toggle");193 cell.column.set("direction", "ascending");194 cell.collection.on("backgrid:sort", function (col, dir) { column = col; direction = dir; });195 cell.$el.find("a").click();196 expect(column).toBe(cell.column);197 expect(direction).toBe("descending");198 });199 it("with `sortType` set to `toggle`, triggers `backgrid:sort` with the column and direction set to 'ascending' if the column's direction is set to 'descending'", function () {200 var column, direction;201 cell.column.set("sortType", "toggle");202 cell.column.set("direction", "descending");203 cell.collection.on("backgrid:sort", function (col, dir) { column = col; direction = dir; });204 cell.$el.find("a").click();205 expect(column).toBe(cell.column);206 expect(direction).toBe("ascending");207 });208});209describe("A HeaderRow", function () {210 var Book = Backbone.Model.extend({});211 var Books = Backbone.Collection.extend({212 model: Book213 });214 var books;215 var row;216 beforeEach(function () {217 books = new Books([{218 title: "Alice's Adventures in Wonderland",219 year: 1865220 }, {221 title: "A Tale of Two Cities",222 year: 1859223 }, {224 title: "The Catcher in the Rye",225 year: 1951226 }]);227 row = new Backgrid.HeaderRow({228 columns: [{229 name: "name",230 cell: "string"231 }, {232 name: "year",233 cell: "integer"234 }],235 collection: books236 });237 row.render();238 });239 it("renders a row of header cells", function () {240 expect(row.$el[0].tagName).toBe("TR");241 var th1 = $(row.el.childNodes[0]);242 expect(th1.hasClass("editable")).toBe(true);243 expect(th1.hasClass("sortable")).toBe(true);244 expect(th1.hasClass("renderable")).toBe(true);245 expect(th1.hasClass("name")).toBe(true);246 expect(th1.find("a").text()).toBe("name");247 expect(th1.find("a").eq(1).is($("b", {className: "sort-caret"})));248 var th2 = $(row.el.childNodes[1]);249 expect(th2.hasClass("editable")).toBe(true);250 expect(th2.hasClass("sortable")).toBe(true);251 expect(th2.hasClass("renderable")).toBe(true);252 expect(th2.hasClass("year")).toBe(true);253 expect(th2.find("a").text()).toBe("year");254 expect(th2.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true);255 });256 it("resets the carets of the non-sorting columns", function () {257 row.$el.find("a").eq(0).click(); // ascending258 row.$el.find("a").eq(1).click(); // ascending, resets the previous259 expect(row.$el.find("a").eq(0).hasClass("ascending")).toBe(false);260 expect(row.$el.find("a").eq(1).hasClass("ascending")).toBe(false);261 });262 it("inserts or removes a cell if a column is added or removed", function () {263 row.columns.add({name: "price", cell: "number"});264 expect(row.$el.children().length).toBe(3);265 var lastTh = $(row.el.lastChild);266 expect(lastTh.hasClass("editable")).toBe(true);267 expect(lastTh.hasClass("sortable")).toBe(true);268 expect(lastTh.hasClass("renderable")).toBe(true);269 expect(lastTh.hasClass("price")).toBe(true);270 expect(lastTh.find("a").text()).toBe("price");271 expect(lastTh.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true);272 row.columns.add({name: "publisher", cell: "string", renderable: false});273 expect(row.$el.children().length).toBe(4);274 expect(row.$el.children().last().find("a").text()).toBe("publisher");275 expect(row.$el.children().last().hasClass("renderable")).toBe(false);276 row.columns.remove(row.columns.first());277 expect(row.$el.children().length).toBe(3);278 var firstTh = $(row.el.firstChild);279 expect(firstTh.hasClass("editable")).toBe(true);280 expect(firstTh.hasClass("sortable")).toBe(true);281 expect(firstTh.hasClass("renderable")).toBe(true);282 expect(firstTh.hasClass("year")).toBe(true);283 expect(firstTh.find("a").text()).toBe("year");284 expect(firstTh.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true);285 });286});287describe("A Header", function () {288 var Book = Backbone.Model.extend({});289 var Books = Backbone.Collection.extend({290 model: Book291 });292 var books;293 var head;294 beforeEach(function () {295 books = new Books([{296 title: "Alice's Adventures in Wonderland",297 year: 1865298 }, {299 title: "A Tale of Two Cities",300 year: 1859301 }, {302 title: "The Catcher in the Rye",303 year: 1951304 }]);305 head = new Backgrid.Header({306 columns: [{307 name: "name",308 cell: "string"309 }, {310 name: "year",311 cell: "integer"312 }],313 collection: books314 });315 head.render();316 });317 it("renders a header with a row of header cells", function () {318 expect(head.$el[0].tagName).toBe("THEAD");319 var th1 = $(head.row.el.childNodes[0]);320 expect(th1.hasClass("editable")).toBe(true);321 expect(th1.hasClass("sortable")).toBe(true);322 expect(th1.hasClass("renderable")).toBe(true);323 expect(th1.hasClass("name")).toBe(true);324 expect(th1.find("a").text()).toBe("name");325 expect(th1.find("a").eq(1).is($("b", {className: "sort-caret"})));326 var th2 = $(head.row.el.childNodes[1]);327 expect(th2.hasClass("editable")).toBe(true);328 expect(th2.hasClass("sortable")).toBe(true);329 expect(th2.hasClass("renderable")).toBe(true);330 expect(th2.hasClass("year")).toBe(true);331 expect(th2.find("a").text()).toBe("year");332 expect(th2.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true);333 });...

Full Screen

Full Screen

has.js.uncompressed.js

Source:has.js.uncompressed.js Github

copy

Full Screen

...75 // | // el == the generic element. a `has` element.76 // | return false; // fake test, byid-when-form-has-name-matching-an-id is slightly longer77 // | });78 (typeof cache[name]=="undefined" || force) && (cache[name]= test);79 return now && has(name);80 };81 // since we're operating under a loader that doesn't provide a has API, we must explicitly initialize82 // has as it would have otherwise been initialized by the dojo loader; use has.add to the builder83 // can optimize these away iff desired84 1 || has.add("host-browser", isBrowser);85 0 && has.add("host-node", (typeof process == "object" && process.versions && process.versions.node && process.versions.v8));86 0 && has.add("host-rhino", (typeof load == "function" && (typeof Packages == "function" || typeof Packages == "object")));87 1 || has.add("dom", isBrowser);88 1 || has.add("dojo-dom-ready-api", 1);89 1 || has.add("dojo-sniff", 1);90 }91 if( 1 ){92 // Common application level tests93 has.add("dom-addeventlistener", !!document.addEventListener);94 // Do the device and browser have touch capability?95 has.add("touch", "ontouchstart" in document96 || ("onpointerdown" in document && navigator.maxTouchPoints > 0)97 || window.navigator.msMaxTouchPoints);98 // Touch events support99 has.add("touch-events", "ontouchstart" in document);100 // Pointer Events support101 has.add("pointer-events", "onpointerdown" in document);102 has.add("MSPointer", "msMaxTouchPoints" in navigator); //IE10 (+IE11 preview)103 // I don't know if any of these tests are really correct, just a rough guess104 has.add("device-width", screen.availWidth || innerWidth);105 // Tests for DOMNode.attributes[] behavior:106 // - dom-attributes-explicit - attributes[] only lists explicitly user specified attributes107 // - dom-attributes-specified-flag (IE8) - need to check attr.specified flag to skip attributes user didn't specify108 // - Otherwise, in IE6-7. attributes[] will list hundreds of values, so need to do outerHTML to get attrs instead.109 var form = document.createElement("form");110 has.add("dom-attributes-explicit", form.attributes.length == 0); // W3C111 has.add("dom-attributes-specified-flag", form.attributes.length > 0 && form.attributes.length < 40); // IE8112 }113 has.clearElement = function(element){114 // summary:115 // Deletes the contents of the element passed to test functions.116 element.innerHTML= "";117 return element;118 };119 has.normalize = function(id, toAbsMid){120 // summary:121 // Resolves id into a module id based on possibly-nested tenary expression that branches on has feature test value(s).122 //123 // toAbsMid: Function124 // Resolves a relative module id into an absolute module id125 var126 tokens = id.match(/[\?:]|[^:\?]*/g), i = 0,127 get = function(skip){128 var term = tokens[i++];129 if(term == ":"){130 // empty string module name, resolves to 0131 return 0;132 }else{133 // postfixed with a ? means it is a feature to branch on, the term is the name of the feature134 if(tokens[i++] == "?"){135 if(!skip && has(term)){136 // matched the feature, get the first value from the options137 return get();138 }else{139 // did not match, get the second value, passing over the first140 get(true);141 return get(skip);142 }143 }144 // a module145 return term || 0;146 }147 };148 id = get();149 return id && toAbsMid(id);...

Full Screen

Full Screen

weeks_in_year.js

Source:weeks_in_year.js Github

copy

Full Screen

1import { module, test } from '../qunit';2import moment from '../../moment';3module('weeks in year');4test('isoWeeksInYear', function (assert) {5 assert.equal(moment([2004]).isoWeeksInYear(), 53, '2004 has 53 iso weeks');6 assert.equal(moment([2005]).isoWeeksInYear(), 52, '2005 has 53 iso weeks');7 assert.equal(moment([2006]).isoWeeksInYear(), 52, '2006 has 53 iso weeks');8 assert.equal(moment([2007]).isoWeeksInYear(), 52, '2007 has 52 iso weeks');9 assert.equal(moment([2008]).isoWeeksInYear(), 52, '2008 has 53 iso weeks');10 assert.equal(moment([2009]).isoWeeksInYear(), 53, '2009 has 53 iso weeks');11 assert.equal(moment([2010]).isoWeeksInYear(), 52, '2010 has 52 iso weeks');12 assert.equal(moment([2011]).isoWeeksInYear(), 52, '2011 has 52 iso weeks');13 assert.equal(moment([2012]).isoWeeksInYear(), 52, '2012 has 52 iso weeks');14 assert.equal(moment([2013]).isoWeeksInYear(), 52, '2013 has 52 iso weeks');15 assert.equal(moment([2014]).isoWeeksInYear(), 52, '2014 has 52 iso weeks');16 assert.equal(moment([2015]).isoWeeksInYear(), 53, '2015 has 53 iso weeks');17});18test('weeksInYear doy/dow = 1/4', function (assert) {19 moment.locale('1/4', {week: {dow: 1, doy: 4}});20 assert.equal(moment([2004]).weeksInYear(), 53, '2004 has 53 weeks');21 assert.equal(moment([2005]).weeksInYear(), 52, '2005 has 53 weeks');22 assert.equal(moment([2006]).weeksInYear(), 52, '2006 has 53 weeks');23 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');24 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');25 assert.equal(moment([2009]).weeksInYear(), 53, '2009 has 53 weeks');26 assert.equal(moment([2010]).weeksInYear(), 52, '2010 has 52 weeks');27 assert.equal(moment([2011]).weeksInYear(), 52, '2011 has 52 weeks');28 assert.equal(moment([2012]).weeksInYear(), 52, '2012 has 52 weeks');29 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');30 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');31 assert.equal(moment([2015]).weeksInYear(), 53, '2015 has 53 weeks');32});33test('weeksInYear doy/dow = 6/12', function (assert) {34 moment.locale('6/12', {week: {dow: 6, doy: 12}});35 assert.equal(moment([2004]).weeksInYear(), 53, '2004 has 53 weeks');36 assert.equal(moment([2005]).weeksInYear(), 52, '2005 has 53 weeks');37 assert.equal(moment([2006]).weeksInYear(), 52, '2006 has 53 weeks');38 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');39 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');40 assert.equal(moment([2009]).weeksInYear(), 52, '2009 has 53 weeks');41 assert.equal(moment([2010]).weeksInYear(), 53, '2010 has 52 weeks');42 assert.equal(moment([2011]).weeksInYear(), 52, '2011 has 52 weeks');43 assert.equal(moment([2012]).weeksInYear(), 52, '2012 has 52 weeks');44 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');45 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');46 assert.equal(moment([2015]).weeksInYear(), 52, '2015 has 53 weeks');47});48test('weeksInYear doy/dow = 1/7', function (assert) {49 moment.locale('1/7', {week: {dow: 1, doy: 7}});50 assert.equal(moment([2004]).weeksInYear(), 52, '2004 has 53 weeks');51 assert.equal(moment([2005]).weeksInYear(), 52, '2005 has 53 weeks');52 assert.equal(moment([2006]).weeksInYear(), 53, '2006 has 53 weeks');53 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');54 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');55 assert.equal(moment([2009]).weeksInYear(), 52, '2009 has 53 weeks');56 assert.equal(moment([2010]).weeksInYear(), 52, '2010 has 52 weeks');57 assert.equal(moment([2011]).weeksInYear(), 52, '2011 has 52 weeks');58 assert.equal(moment([2012]).weeksInYear(), 53, '2012 has 52 weeks');59 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');60 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');61 assert.equal(moment([2015]).weeksInYear(), 52, '2015 has 53 weeks');62});63test('weeksInYear doy/dow = 0/6', function (assert) {64 moment.locale('0/6', {week: {dow: 0, doy: 6}});65 assert.equal(moment([2004]).weeksInYear(), 52, '2004 has 53 weeks');66 assert.equal(moment([2005]).weeksInYear(), 53, '2005 has 53 weeks');67 assert.equal(moment([2006]).weeksInYear(), 52, '2006 has 53 weeks');68 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');69 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');70 assert.equal(moment([2009]).weeksInYear(), 52, '2009 has 53 weeks');71 assert.equal(moment([2010]).weeksInYear(), 52, '2010 has 52 weeks');72 assert.equal(moment([2011]).weeksInYear(), 53, '2011 has 52 weeks');73 assert.equal(moment([2012]).weeksInYear(), 52, '2012 has 52 weeks');74 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');75 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');76 assert.equal(moment([2015]).weeksInYear(), 52, '2015 has 53 weeks');...

Full Screen

Full Screen

hive_cell_emoji.py

Source:hive_cell_emoji.py Github

copy

Full Screen

1import operator2import random as random_module3class HiveCellEmoji(object):4 all_cells = set()5 def __init__(self, emoji, flags, weight: int = 100):6 self.emoji = emoji7 self.flags = flags8 self.weight = weight9 self.all_cells.add(self)10 @classmethod11 def get_cell(cls, flags, noflags, *, random: random_module.Random = None):12 valid_cells = [i for i in cls.all_cells if set(i.flags).issuperset(set(flags)) and not set(i.flags).intersection(set(noflags))]13 valid_cells.sort(key=operator.attrgetter("weight"))14 return (random or random_module).choices(valid_cells, weights=[i.weight for i in valid_cells], k=1)[0]15 @classmethod16 def get_grid(cls, width: int = 9, height: int = 9, *, random: random_module.Random = None):17 """18 Make a grid of hive cell emojis.19 """20 # Make our initial grid21 grid = [[None for inner in range(width)] for outer in range(height)]22 # Go through each grid cell23 for y in range(0, height):24 for x in range(0, width):25 # Set up our filters26 search_cells = set()27 nosearch_cells = set()28 # See if there's a cell above29 if y:30 above = grid[y - 1][x]31 if "HAS_BOTTOM" in above.flags:32 search_cells.add("HAS_TOP")33 else:34 nosearch_cells.add("HAS_TOP")35 # See if there's a cell to the left36 if x:37 left = grid[y][x - 1]38 if "HAS_RIGHT" in left.flags:39 search_cells.add("HAS_LEFT")40 else:41 nosearch_cells.add("HAS_LEFT")42 # See if we're EDGING BABY43 if x == 0:44 nosearch_cells.add("HAS_LEFT")45 if x == width - 1:46 nosearch_cells.add("HAS_RIGHT")47 if y == 0:48 nosearch_cells.add("HAS_TOP")49 if y == height - 1:50 nosearch_cells.add("HAS_BOTTOM")51 # Find a relevant cell52 new_cell = cls.get_cell(search_cells, nosearch_cells, random=random)53 grid[y][x] = new_cell54 # Join and return55 output_lines = list()56 for i in grid:57 output_lines.append("".join([o.emoji for o in i]))58 return "\n".join(output_lines)59HiveCellEmoji("<:HiveCell:864882083884171264>", ["HAS_MIDDLE", "HAS_TOP", "HAS_LEFT", "HAS_RIGHT", "HAS_BOTTOM"], weight=100)60HiveCellEmoji("<:HiveCellMissingTop:864882084023894027>", ["HAS_LEFT", "HAS_MIDDLE", "HAS_RIGHT", "HAS_BOTTOM"], weight=90)61HiveCellEmoji("<:HiveCellMissingRight:864883719676231680>", ["HAS_LEFT", "HAS_MIDDLE", "HAS_TOP", "HAS_BOTTOM"], weight=90)62HiveCellEmoji("<:HiveCellMissingMiddle:864882083884171267>", ["HAS_LEFT", "HAS_TOP", "HAS_BOTTOM", "HAS_RIGHT"], weight=90)63HiveCellEmoji("<:HiveCellMissingLeft:864883719664173098>", ["HAS_TOP", "HAS_BOTTOM", "HAS_MIDDLE", "HAS_RIGHT"], weight=90)64HiveCellEmoji("<:HiveCellMissingBottom:864882084195205180>", ["HAS_MIDDLE", "HAS_TOP", "HAS_LEFT", "HAS_RIGHT"], weight=90)65HiveCellEmoji("<:HiveCellMissingTopBottom:864883719398752297>", ["HAS_LEFT", "HAS_MIDDLE", "HAS_RIGHT"], weight=40)66HiveCellEmoji("<:HiveCellMissingSides:864883719797735454>", ["HAS_MIDDLE", "HAS_TOP", "HAS_BOTTOM"], weight=40)67HiveCellEmoji("<:HiveCellOnlyTop:865091796420788284>", ["HAS_MIDDLE", "HAS_TOP"], weight=30)68HiveCellEmoji("<:HiveCellOnlyRight:865091796023246868>", ["HAS_MIDDLE", "HAS_RIGHT"], weight=30)69HiveCellEmoji("<:HiveCellOnlyLeft:865091796186955828>", ["HAS_MIDDLE", "HAS_LEFT"], weight=30)70HiveCellEmoji("<:HiveCellOnlyBottom:865091795797016596>", ["HAS_MIDDLE", "HAS_BOTTOM"], weight=30)71HiveCellEmoji("<:HiveCellOnlyMiddle:865094728940126218>", ["HAS_MIDDLE"], weight=30)72HiveCellEmoji("<:HiveCellEmpty:865094728420294676>", [], weight=10)73HiveCellEmoji("<:HiveCellMissingCornerTR:864883719779909672>", ["HAS_MIDDLE", "HAS_LEFT", "HAS_BOTTOM"], weight=10)74HiveCellEmoji("<:HiveCellMissingCornerTL:864883719613448202>", ["HAS_MIDDLE", "HAS_RIGHT", "HAS_BOTTOM"], weight=10)75HiveCellEmoji("<:HiveCellMissingCornerBR:864883719664173096>", ["HAS_MIDDLE", "HAS_TOP", "HAS_LEFT"], weight=10)...

Full Screen

Full Screen

config.js.uncompressed.js

Source:config.js.uncompressed.js Github

copy

Full Screen

...26 var parts = hasname.split(',');27 if(parts.length > 0){28 while(parts.length > 0){ 29 var haspart = parts.shift();30 // check for has(haspart) or if haspart starts with ! check for !(has(haspart))31 if((has(haspart)) || (haspart.charAt(0) == '!' && !(has(haspart.substring(1))))){ // if true this one should be merged32 var hasval = sval[hasname];33 this.configMerge(source, hasval); // merge this has section into the source config34 break; // found a match for this multiple has test, so go to the next one35 }36 }37 }38 }39 }40 delete source["has"]; // after merge remove this has section from the config41 }else{42 if(!(name.charAt(0) == '_' && name.charAt(1) == '_') && sval && typeof sval === 'object'){43 this.configProcessHas(sval);44 }45 }...

Full Screen

Full Screen

asStripClasses.js

Source:asStripClasses.js Github

copy

Full Screen

1// DATA_TEMPLATE: dom_data2oTest.fnStart( "asStripeClasses" );3$(document).ready( function () {4 /* Check the default */5 $('#example').dataTable();6 7 oTest.fnTest( 8 "Default row striping is applied",9 null,10 function () {11 return $('#example tbody tr:eq(0)').hasClass('odd') &&12 $('#example tbody tr:eq(1)').hasClass('even') &&13 $('#example tbody tr:eq(2)').hasClass('odd') &&14 $('#example tbody tr:eq(3)').hasClass('even');15 }16 );17 18 oTest.fnTest( 19 "Row striping does not effect current classes",20 null,21 function () {22 return $('#example tbody tr:eq(0)').hasClass('gradeA') &&23 $('#example tbody tr:eq(1)').hasClass('gradeA') &&24 $('#example tbody tr:eq(2)').hasClass('gradeA') &&25 $('#example tbody tr:eq(3)').hasClass('gradeA');26 }27 );28 29 oTest.fnTest( 30 "Row striping on the second page",31 function () { $('#example_next').click(); },32 function () {33 return $('#example tbody tr:eq(0)').hasClass('odd') &&34 $('#example tbody tr:eq(1)').hasClass('even') &&35 $('#example tbody tr:eq(2)').hasClass('odd') &&36 $('#example tbody tr:eq(3)').hasClass('even');37 }38 );39 40 /* No striping */41 oTest.fnTest( 42 "No row striping",43 function () {44 oSession.fnRestore();45 $('#example').dataTable( {46 "asStripeClasses": []47 } );48 },49 function () {50 return $('#example tbody tr:eq(0)')[0].className == "gradeA" &&51 $('#example tbody tr:eq(1)')[0].className == "gradeA" &&52 $('#example tbody tr:eq(2)')[0].className == "gradeA" &&53 $('#example tbody tr:eq(3)')[0].className == "gradeA";54 }55 );56 57 /* Custom striping */58 oTest.fnTest( 59 "Custom striping [2]",60 function () {61 oSession.fnRestore();62 $('#example').dataTable( {63 "asStripeClasses": [ 'test1', 'test2' ]64 } );65 },66 function () {67 return $('#example tbody tr:eq(0)').hasClass('test1') &&68 $('#example tbody tr:eq(1)').hasClass('test2') &&69 $('#example tbody tr:eq(2)').hasClass('test1') &&70 $('#example tbody tr:eq(3)').hasClass('test2');71 }72 );73 74 75 /* long array of striping */76 oTest.fnTest( 77 "Custom striping [4]",78 function () {79 oSession.fnRestore();80 $('#example').dataTable( {81 "asStripeClasses": [ 'test1', 'test2', 'test3', 'test4' ]82 } );83 },84 function () {85 return $('#example tbody tr:eq(0)').hasClass('test1') &&86 $('#example tbody tr:eq(1)').hasClass('test2') &&87 $('#example tbody tr:eq(2)').hasClass('test3') &&88 $('#example tbody tr:eq(3)').hasClass('test4');89 }90 );91 92 oTest.fnTest( 93 "Custom striping is restarted on second page [2]",94 function () { $('#example_next').click(); },95 function () {96 return $('#example tbody tr:eq(0)').hasClass('test1') &&97 $('#example tbody tr:eq(1)').hasClass('test2') &&98 $('#example tbody tr:eq(2)').hasClass('test3') &&99 $('#example tbody tr:eq(3)').hasClass('test4');100 }101 );102 103 104 oTest.fnComplete();...

Full Screen

Full Screen

sniff.js.uncompressed.js

Source:sniff.js.uncompressed.js Github

copy

Full Screen

...3 // dojo/sniff4 /*=====5 return function(){6 // summary:7 // This module sets has() flags based on the current browser.8 // It returns the has() function.9 };10 =====*/11 if( 1 ){12 var n = navigator,13 dua = n.userAgent,14 dav = n.appVersion,15 tv = parseFloat(dav);16 has.add("air", dua.indexOf("AdobeAIR") >= 0);17 has.add("msapp", parseFloat(dua.split("MSAppHost/")[1]) || undefined);18 has.add("khtml", dav.indexOf("Konqueror") >= 0 ? tv : undefined);19 has.add("webkit", parseFloat(dua.split("WebKit/")[1]) || undefined);20 has.add("chrome", parseFloat(dua.split("Chrome/")[1]) || undefined);21 has.add("safari", dav.indexOf("Safari")>=0 && !has("chrome") ? parseFloat(dav.split("Version/")[1]) : undefined);22 has.add("mac", dav.indexOf("Macintosh") >= 0);23 has.add("quirks", document.compatMode == "BackCompat");24 if(dua.match(/(iPhone|iPod|iPad)/)){25 var p = RegExp.$1.replace(/P/, "p");26 var v = dua.match(/OS ([\d_]+)/) ? RegExp.$1 : "1";27 var os = parseFloat(v.replace(/_/, ".").replace(/_/g, ""));28 has.add(p, os); // "iphone", "ipad" or "ipod"29 has.add("ios", os);30 }31 has.add("android", parseFloat(dua.split("Android ")[1]) || undefined);32 has.add("bb", (dua.indexOf("BlackBerry") >= 0 || dua.indexOf("BB10") >= 0) && parseFloat(dua.split("Version/")[1]) || undefined);33 has.add("trident", parseFloat(dav.split("Trident/")[1]) || undefined);34 has.add("svg", typeof SVGAngle !== "undefined");35 if(!has("webkit")){36 // Opera37 if(dua.indexOf("Opera") >= 0){38 // see http://dev.opera.com/articles/view/opera-ua-string-changes and http://www.useragentstring.com/pages/Opera/39 // 9.8 has both styles; <9.8, 9.9 only old style40 has.add("opera", tv >= 9.8 ? parseFloat(dua.split("Version/")[1]) || tv : tv);41 }42 // Mozilla and firefox43 if(dua.indexOf("Gecko") >= 0 && !has("khtml") && !has("webkit") && !has("trident")){44 has.add("mozilla", tv);45 }46 if(has("mozilla")){47 //We really need to get away from this. Consider a sane isGecko approach for the future.48 has.add("ff", parseFloat(dua.split("Firefox/")[1] || dua.split("Minefield/")[1]) || undefined);49 }50 // IE51 if(document.all && !has("opera")){52 var isIE = parseFloat(dav.split("MSIE ")[1]) || undefined;53 //In cases where the page has an HTTP header or META tag with54 //X-UA-Compatible, then it is in emulation mode.55 //Make sure isIE reflects the desired version.56 //document.documentMode of 5 means quirks mode.57 //Only switch the value if documentMode's major version58 //is different from isIE's major version.59 var mode = document.documentMode;60 if(mode && mode != 5 && Math.floor(isIE) != mode){61 isIE = mode;62 }63 has.add("ie", isIE);64 }65 // Wii...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.screenshot({ path: 'example.png' });6 await browser.close();7})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { has } = require('playwright/lib/internal/utils/utils');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 if (has(page, 'screenshot')) {7 await page.screenshot({ path: 'example.png' });8 }9 await browser.close();10})();11#### 2.1.1. `BrowserContext.addCookies(cookies)`12#### 2.1.2. `BrowserContext.clearCookies()`13#### 2.1.3. `BrowserContext.clearPermissions()`14#### 2.1.4. `BrowserContext.close()`15#### 2.1.5. `BrowserContext.cookies(urls)`16#### 2.1.6. `BrowserContext.exposeBinding(name, playwrightBinding)`

Full Screen

Using AI Code Generation

copy

Full Screen

1const { has } = require('@playwright/test');2const { test } = require('@playwright/test');3test('test', async ({ page }) => {4 if (await has('text=Get started')) {5 console.log('Found Get started text');6 } else {7 console.log('Get started text not found');8 }9});10### **Test.skip()**11const { test } = require('@playwright/test');12test.skip('test', async ({ page }) => {13 if (await has('text=Get started')) {14 console.log('Found Get started text');15 } else {16 console.log('Get started text not found');17 }18});19### **Test.fixme()**20const { test } = require('@playwright/test');21test.fixme('test', async ({ page }) => {22 if (await has('text=Get started')) {23 console.log('Found Get started text');24 } else {25 console.log('Get started text not found');26 }27});28### **Test.beforeAll()**29const { test } = require('@playwright/test');30test.beforeAll(async () => {31});32test('test', async ({ page }) => {33 if (await has('text=Get started')) {34 console.log('Found Get started text');35 } else {36 console.log('Get started text not found');37 }38});39### **Test.beforeEach()**

Full Screen

Using AI Code Generation

copy

Full Screen

1import { has } from '@playwright/test';2if (has('video')) {3 console.log('Video is enabled');4} else {5 console.log('Video is disabled');6}7import { test } from '@playwright/test';8test.use({ param1: 'value1' });9test('test with parameter', async ({ param1 }) => {10});11import { test } from '@playwright/test';12test.use({ param1: 'value1', param2: 'value2' });13test('test with parameter', async ({ param1, param2 }) => {14});15import { test } from '@playwright/test';16test.use({ param1: 'value1' });17test.beforeEach(async ({ param1 }) => {18});19test('test with parameter', async () => {20});21import { test } from '@playwright/test';22test.fixtures({23 param1: async ({}, use) => {24 await use('value1');25 },26});27test('test with parameter', async ({ param1 }) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toHaveNoViolations } = require('jest-axe');2expect.extend(toHaveNoViolations);3describe('Accessibility tests', () => {4 it('should not have any accessibility violations', async () => {5 const page = await browser.newPage();6 const results = await page.accessibility.snapshot();7 expect(results).toHaveNoViolations();8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { has } = require('@playwright/test');2const { isAndroid, isChrome, isChromium, isFirefox, isIOS, isMac, isMobile, isWebKit } = require('@playwright/test');3const { isAndroid, isChrome, isChromium, isFirefox, isIOS, isMac, isMobile, isWebKit } = require('@playwright/test');4const { isAndroid, isChrome, isChromium, isFirefox, isIOS, isMac, isMobile, isWebKit } = require('@playwright/test');5const { isAndroid, isChrome, isChromium, isFirefox, isIOS, isMac, isMobile, isWebKit } = require('@playwright/test');6const { isAndroid, isChrome, isChromium, isFirefox, isIOS, isMac, isMobile, isWebKit } = require('@playwright/test');7const { isAndroid, isChrome, isChromium, isFirefox, isIOS, isMac, isMobile, isWebKit } = require('@playwright/test');8const { isAndroid, isChrome, isChromium, isFirefox, isIOS, isMac, isMobile, isWebKit } = require('@playwright/test');9const { isAndroid, isChrome, isChromium, isFirefox, isIOS, isMac, isMobile, isWebKit } = require('@playwright/test');10const { isAndroid, isChrome, isChromium, isFirefox, isIOS, isMac, isMobile, isWebKit } = require('@playwright/test');11const { isAndroid, isChrome, isChromium, isFirefox, isIOS, isMac, isMobile, isWebKit } = require('@playwright/test');12const { isAndroid, isChrome, isChromium, isFirefox

Full Screen

Using AI Code Generation

copy

Full Screen

1const { has } = require('playwright/lib/utils/utils');2console.log(has({a: 1}, 'a'));3const { has } = require('playwright/lib/utils/utils');4console.log(has({a: 1}, 'b'));5const { has } = require('playwright/lib/utils/utils');6console.log(has({a: 1}, 'toString'));7const { has } = require('playwright/lib/utils/utils');8console.log(has({a: 1}, 'valueOf'));9const { has } = require('playwright/lib/utils/utils');10console.log(has({a: 1}, 'hasOwnProperty'));11const { has } = require('playwright/lib/utils/utils');12console.log(has({a: 1}, 'isPrototypeOf'));13const { has } = require('playwright/lib/utils/utils');14console.log(has({a: 1}, 'propertyIsEnumerable'));15const { has } = require('playwright/lib/utils/utils');16console.log(has({a: 1}, '__defineGetter__'));17const { has } = require('playwright/lib/utils/utils');18console.log(has({a: 1}, '__defineSetter__'));19const { has } = require('playwright/lib/utils/utils');20console.log(has({a: 1}, '__lookupGetter__'));21const { has } = require('playwright/lib/utils/utils');22console.log(has({a: 1}, '__lookupSetter__'));23const { has } = require('playwright/lib/utils/utils');24console.log(has({a: 1}, '__

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful