How to use isEnabled method in Playwright Internal

Best JavaScript code snippet using playwright-internal

tableui.js

Source:tableui.js Github

copy

Full Screen

1/**2 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license4 */5/* global document */6import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';7import { _clear as clearTranslations, add as addTranslations } from '@ckeditor/ckeditor5-utils/src/translation-service';8import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';9import TableEditing from '../src/tableediting';10import TableUI from '../src/tableui';11import InsertTableView from '../src/ui/inserttableview';12import SwitchButtonView from '@ckeditor/ckeditor5-ui/src/button/switchbuttonview';13import DropdownView from '@ckeditor/ckeditor5-ui/src/dropdown/dropdownview';14import ListSeparatorView from '@ckeditor/ckeditor5-ui/src/list/listseparatorview';15import SplitButtonView from '@ckeditor/ckeditor5-ui/src/dropdown/button/splitbuttonview';16describe( 'TableUI', () => {17 let editor, element;18 testUtils.createSinonSandbox();19 before( () => {20 addTranslations( 'en', {} );21 addTranslations( 'pl', {} );22 } );23 after( () => {24 clearTranslations();25 } );26 beforeEach( () => {27 element = document.createElement( 'div' );28 document.body.appendChild( element );29 return ClassicTestEditor30 .create( element, {31 plugins: [ TableEditing, TableUI ]32 } )33 .then( newEditor => {34 editor = newEditor;35 } );36 } );37 afterEach( () => {38 element.remove();39 return editor.destroy();40 } );41 describe( 'insertTable dropdown', () => {42 let insertTable;43 beforeEach( () => {44 insertTable = editor.ui.componentFactory.create( 'insertTable' );45 insertTable.isOpen = true; // Dropdown is lazy loaded, so make sure its open (#6193).46 } );47 it( 'should register insertTable button', () => {48 expect( insertTable ).to.be.instanceOf( DropdownView );49 expect( insertTable.buttonView.label ).to.equal( 'Insert table' );50 expect( insertTable.buttonView.icon ).to.match( /<svg / );51 } );52 it( 'should bind to insertTable command', () => {53 const command = editor.commands.get( 'insertTable' );54 command.isEnabled = true;55 expect( insertTable.buttonView.isOn ).to.be.true;56 expect( insertTable.buttonView.isEnabled ).to.be.true;57 command.isEnabled = false;58 expect( insertTable.buttonView.isEnabled ).to.be.false;59 } );60 it( 'should execute insertTable command on button execute event', () => {61 const executeSpy = testUtils.sinon.spy( editor, 'execute' );62 const tableSizeView = insertTable.panelView.children.first;63 tableSizeView.rows = 2;64 tableSizeView.columns = 7;65 insertTable.fire( 'execute' );66 sinon.assert.calledOnce( executeSpy );67 sinon.assert.calledWithExactly( executeSpy, 'insertTable', { rows: 2, columns: 7 } );68 } );69 it( 'should reset rows & columns on dropdown open', () => {70 insertTable.isOpen = true;71 const tableSizeView = insertTable.panelView.children.first;72 expect( tableSizeView.rows ).to.equal( 0 );73 expect( tableSizeView.columns ).to.equal( 0 );74 tableSizeView.rows = 2;75 tableSizeView.columns = 2;76 insertTable.buttonView.fire( 'open' );77 expect( tableSizeView.rows ).to.equal( 0 );78 expect( tableSizeView.columns ).to.equal( 0 );79 } );80 it( 'is not fully initialized when not open', () => {81 const dropdown = editor.ui.componentFactory.create( 'insertTable' );82 for ( const childView of dropdown.panelView.children ) {83 expect( childView ).not.to.be.instanceOf( InsertTableView );84 }85 } );86 } );87 describe( 'tableRow dropdown', () => {88 let dropdown;89 beforeEach( () => {90 dropdown = editor.ui.componentFactory.create( 'tableRow' );91 } );92 it( 'have button with proper properties set', () => {93 expect( dropdown ).to.be.instanceOf( DropdownView );94 const button = dropdown.buttonView;95 expect( button.isOn ).to.be.false;96 expect( button.tooltip ).to.be.true;97 expect( button.label ).to.equal( 'Row' );98 expect( button.icon ).to.match( /<svg / );99 } );100 it( 'should have proper items in panel', () => {101 const listView = dropdown.listView;102 const labels = listView.items.map( item => item instanceof ListSeparatorView ? '|' : item.children.first.label );103 expect( labels ).to.deep.equal(104 [ 'Header row', '|', 'Insert row above', 'Insert row below', 'Delete row', 'Select row' ]105 );106 } );107 it( 'should bind items in panel to proper commands', () => {108 const items = dropdown.listView.items;109 const setRowHeaderCommand = editor.commands.get( 'setTableRowHeader' );110 const insertRowBelowCommand = editor.commands.get( 'insertTableRowBelow' );111 const insertRowAboveCommand = editor.commands.get( 'insertTableRowAbove' );112 const removeRowCommand = editor.commands.get( 'removeTableRow' );113 const selectRowCommand = editor.commands.get( 'selectTableRow' );114 setRowHeaderCommand.isEnabled = true;115 insertRowBelowCommand.isEnabled = true;116 insertRowAboveCommand.isEnabled = true;117 removeRowCommand.isEnabled = true;118 selectRowCommand.isEnabled = true;119 expect( items.first.children.first.isEnabled ).to.be.true;120 expect( items.get( 2 ).children.first.isEnabled ).to.be.true;121 expect( items.get( 3 ).children.first.isEnabled ).to.be.true;122 expect( items.get( 4 ).children.first.isEnabled ).to.be.true;123 expect( items.get( 5 ).children.first.isEnabled ).to.be.true;124 expect( dropdown.buttonView.isEnabled ).to.be.true;125 setRowHeaderCommand.isEnabled = false;126 expect( items.first.children.first.isEnabled ).to.be.false;127 expect( dropdown.buttonView.isEnabled ).to.be.true;128 insertRowAboveCommand.isEnabled = false;129 expect( items.get( 2 ).children.first.isEnabled ).to.be.false;130 expect( dropdown.buttonView.isEnabled ).to.be.true;131 insertRowBelowCommand.isEnabled = false;132 expect( items.get( 3 ).children.first.isEnabled ).to.be.false;133 expect( dropdown.buttonView.isEnabled ).to.be.true;134 removeRowCommand.isEnabled = false;135 expect( items.get( 4 ).children.first.isEnabled ).to.be.false;136 expect( dropdown.buttonView.isEnabled ).to.be.true;137 selectRowCommand.isEnabled = false;138 expect( items.get( 5 ).children.first.isEnabled ).to.be.false;139 expect( dropdown.buttonView.isEnabled ).to.be.false;140 } );141 it( 'should focus view after command execution', () => {142 const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );143 dropdown.listView.items.first.children.first.fire( 'execute' );144 sinon.assert.calledOnce( focusSpy );145 } );146 it( 'executes command when it\'s executed', () => {147 const spy = sinon.stub( editor, 'execute' );148 dropdown.listView.items.first.children.first.fire( 'execute' );149 expect( spy.calledOnce ).to.be.true;150 expect( spy.args[ 0 ][ 0 ] ).to.equal( 'setTableRowHeader' );151 } );152 it( 'should use a toggle switch for the setTableRowHeader item', () => {153 const items = dropdown.listView.items;154 expect( items.first.children.first ).to.be.instanceOf( SwitchButtonView );155 } );156 it( 'should bind set header row command value to dropdown item', () => {157 const items = dropdown.listView.items;158 const setRowHeaderCommand = editor.commands.get( 'setTableRowHeader' );159 setRowHeaderCommand.value = false;160 expect( items.first.children.first.isOn ).to.be.false;161 setRowHeaderCommand.value = true;162 expect( items.first.children.first.isOn ).to.be.true;163 } );164 } );165 describe( 'tableColumn dropdown', () => {166 let dropdown;167 beforeEach( () => {168 dropdown = editor.ui.componentFactory.create( 'tableColumn' );169 } );170 it( 'have button with proper properties set', () => {171 expect( dropdown ).to.be.instanceOf( DropdownView );172 const button = dropdown.buttonView;173 expect( button.isOn ).to.be.false;174 expect( button.tooltip ).to.be.true;175 expect( button.label ).to.equal( 'Column' );176 expect( button.icon ).to.match( /<svg / );177 } );178 it( 'should have proper items in panel', () => {179 const listView = dropdown.listView;180 const labels = listView.items.map( item => item instanceof ListSeparatorView ? '|' : item.children.first.label );181 expect( labels ).to.deep.equal(182 [ 'Header column', '|', 'Insert column left', 'Insert column right', 'Delete column', 'Select column' ]183 );184 } );185 it( 'should bind items in panel to proper commands (LTR content)', () => {186 const items = dropdown.listView.items;187 const setColumnHeaderCommand = editor.commands.get( 'setTableColumnHeader' );188 const insertColumnLeftCommand = editor.commands.get( 'insertTableColumnLeft' );189 const insertColumnRightCommand = editor.commands.get( 'insertTableColumnRight' );190 const removeColumnCommand = editor.commands.get( 'removeTableColumn' );191 const selectColumnCommand = editor.commands.get( 'selectTableColumn' );192 setColumnHeaderCommand.isEnabled = true;193 insertColumnLeftCommand.isEnabled = true;194 insertColumnRightCommand.isEnabled = true;195 removeColumnCommand.isEnabled = true;196 selectColumnCommand.isEnabled = true;197 expect( items.first.children.first.isEnabled ).to.be.true;198 expect( items.get( 2 ).children.first.isEnabled ).to.be.true;199 expect( items.get( 3 ).children.first.isEnabled ).to.be.true;200 expect( items.get( 4 ).children.first.isEnabled ).to.be.true;201 expect( items.get( 5 ).children.first.isEnabled ).to.be.true;202 expect( dropdown.buttonView.isEnabled ).to.be.true;203 setColumnHeaderCommand.isEnabled = false;204 expect( items.first.children.first.isEnabled ).to.be.false;205 expect( dropdown.buttonView.isEnabled ).to.be.true;206 insertColumnLeftCommand.isEnabled = false;207 expect( items.get( 2 ).children.first.isEnabled ).to.be.false;208 expect( dropdown.buttonView.isEnabled ).to.be.true;209 insertColumnRightCommand.isEnabled = false;210 expect( items.get( 3 ).children.first.isEnabled ).to.be.false;211 removeColumnCommand.isEnabled = false;212 expect( items.get( 4 ).children.first.isEnabled ).to.be.false;213 selectColumnCommand.isEnabled = false;214 expect( items.get( 5 ).children.first.isEnabled ).to.be.false;215 expect( dropdown.buttonView.isEnabled ).to.be.false;216 } );217 it( 'should bind items in panel to proper commands (RTL content)', () => {218 const element = document.createElement( 'div' );219 document.body.appendChild( element );220 return ClassicTestEditor221 .create( element, {222 language: {223 ui: 'en',224 content: 'ar'225 },226 plugins: [ TableEditing, TableUI ]227 } )228 .then( editor => {229 const dropdown = editor.ui.componentFactory.create( 'tableColumn' );230 const items = dropdown.listView.items;231 expect( items.get( 2 ).children.first.label ).to.equal( 'Insert column left' );232 expect( items.get( 2 ).children.first.commandName ).to.equal( 'insertTableColumnRight' );233 expect( items.get( 3 ).children.first.label ).to.equal( 'Insert column right' );234 expect( items.get( 3 ).children.first.commandName ).to.equal( 'insertTableColumnLeft' );235 element.remove();236 return editor.destroy();237 } );238 } );239 it( 'should focus view after command execution', () => {240 const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );241 dropdown.listView.items.first.children.first.fire( 'execute' );242 sinon.assert.calledOnce( focusSpy );243 } );244 it( 'executes command when it\'s executed', () => {245 const spy = sinon.stub( editor, 'execute' );246 dropdown.listView.items.first.children.first.fire( 'execute' );247 expect( spy.calledOnce ).to.be.true;248 expect( spy.args[ 0 ][ 0 ] ).to.equal( 'setTableColumnHeader' );249 } );250 it( 'should use a toggle switch for the setTableColumnHeader item', () => {251 const items = dropdown.listView.items;252 expect( items.first.children.first ).to.be.instanceOf( SwitchButtonView );253 } );254 it( 'should bind set header column command value to dropdown item', () => {255 const items = dropdown.listView.items;256 const setColumnHeaderCommand = editor.commands.get( 'setTableColumnHeader' );257 setColumnHeaderCommand.value = false;258 expect( items.first.children.first.isOn ).to.be.false;259 setColumnHeaderCommand.value = true;260 expect( items.first.children.first.isOn ).to.be.true;261 } );262 } );263 describe( 'mergeTableCell split button', () => {264 let dropdown, command;265 beforeEach( () => {266 dropdown = editor.ui.componentFactory.create( 'mergeTableCells' );267 command = editor.commands.get( 'mergeTableCells' );268 } );269 it( 'have button with proper properties set', () => {270 expect( dropdown ).to.be.instanceOf( DropdownView );271 const button = dropdown.buttonView;272 expect( button.isOn ).to.be.false;273 expect( button.tooltip ).to.be.true;274 expect( button.label ).to.equal( 'Merge cells' );275 expect( button.icon ).to.match( /<svg / );276 } );277 it( 'should have a split button', () => {278 expect( dropdown.buttonView ).to.be.instanceOf( SplitButtonView );279 } );280 it( 'should be disabled if all of the merge commands are disabled, along with the main merge command', () => {281 [282 'mergeTableCells',283 'mergeTableCellUp',284 'mergeTableCellRight',285 'mergeTableCellDown',286 'mergeTableCellLeft',287 'splitTableCellVertically',288 'splitTableCellHorizontally'289 ].forEach( command => {290 editor.commands.get( command ).isEnabled = false;291 } );292 expect( dropdown.isEnabled ).to.be.false;293 editor.commands.get( 'mergeTableCellLeft' ).isEnabled = true;294 expect( dropdown.isEnabled ).to.be.true;295 editor.commands.get( 'mergeTableCellLeft' ).isEnabled = false;296 command.isEnabled = true;297 expect( dropdown.isEnabled ).to.be.true;298 } );299 it( 'should execute the "mergeTableCells" command when the main part of the split button is clicked', () => {300 const spy = sinon.stub( editor, 'execute' );301 dropdown.buttonView.fire( 'execute' );302 sinon.assert.calledOnce( spy );303 sinon.assert.calledWithExactly( spy, 'mergeTableCells' );304 } );305 it( 'should have proper items in panel', () => {306 const listView = dropdown.listView;307 const labels = listView.items.map( item => item instanceof ListSeparatorView ? '|' : item.children.first.label );308 expect( labels ).to.deep.equal( [309 'Merge cell up',310 'Merge cell right',311 'Merge cell down',312 'Merge cell left',313 '|',314 'Split cell vertically',315 'Split cell horizontally'316 ] );317 } );318 it( 'should bind items in panel to proper commands (LTR content)', () => {319 const items = dropdown.listView.items;320 const mergeCellUpCommand = editor.commands.get( 'mergeTableCellUp' );321 const mergeCellRightCommand = editor.commands.get( 'mergeTableCellRight' );322 const mergeCellDownCommand = editor.commands.get( 'mergeTableCellDown' );323 const mergeCellLeftCommand = editor.commands.get( 'mergeTableCellLeft' );324 const splitCellVerticallyCommand = editor.commands.get( 'splitTableCellVertically' );325 const splitCellHorizontallyCommand = editor.commands.get( 'splitTableCellHorizontally' );326 mergeCellUpCommand.isEnabled = true;327 mergeCellRightCommand.isEnabled = true;328 mergeCellDownCommand.isEnabled = true;329 mergeCellLeftCommand.isEnabled = true;330 splitCellVerticallyCommand.isEnabled = true;331 splitCellHorizontallyCommand.isEnabled = true;332 const mergeCellUpButton = items.first;333 const mergeCellRightButton = items.get( 1 );334 const mergeCellDownButton = items.get( 2 );335 const mergeCellLeftButton = items.get( 3 );336 // separator337 const splitVerticallyButton = items.get( 5 );338 const splitHorizontallyButton = items.get( 6 );339 expect( mergeCellUpButton.children.first.isEnabled ).to.be.true;340 expect( mergeCellRightButton.children.first.isEnabled ).to.be.true;341 expect( mergeCellDownButton.children.first.isEnabled ).to.be.true;342 expect( mergeCellLeftButton.children.first.isEnabled ).to.be.true;343 expect( splitVerticallyButton.children.first.isEnabled ).to.be.true;344 expect( splitHorizontallyButton.children.first.isEnabled ).to.be.true;345 mergeCellUpCommand.isEnabled = false;346 expect( mergeCellUpButton.children.first.isEnabled ).to.be.false;347 mergeCellRightCommand.isEnabled = false;348 expect( mergeCellRightButton.children.first.isEnabled ).to.be.false;349 mergeCellDownCommand.isEnabled = false;350 expect( mergeCellDownButton.children.first.isEnabled ).to.be.false;351 mergeCellLeftCommand.isEnabled = false;352 expect( mergeCellLeftButton.children.first.isEnabled ).to.be.false;353 splitCellVerticallyCommand.isEnabled = false;354 expect( splitVerticallyButton.children.first.isEnabled ).to.be.false;355 splitCellHorizontallyCommand.isEnabled = false;356 expect( splitHorizontallyButton.children.first.isEnabled ).to.be.false;357 } );358 it( 'should bind items in panel to proper commands (RTL content)', () => {359 const element = document.createElement( 'div' );360 document.body.appendChild( element );361 return ClassicTestEditor362 .create( element, {363 language: {364 ui: 'en',365 content: 'ar'366 },367 plugins: [ TableEditing, TableUI ]368 } )369 .then( editor => {370 const dropdown = editor.ui.componentFactory.create( 'mergeTableCells' );371 const items = dropdown.listView.items;372 expect( items.get( 1 ).children.first.label ).to.equal( 'Merge cell right' );373 expect( items.get( 1 ).children.first.commandName ).to.equal( 'mergeTableCellLeft' );374 expect( items.get( 3 ).children.first.label ).to.equal( 'Merge cell left' );375 expect( items.get( 3 ).children.first.commandName ).to.equal( 'mergeTableCellRight' );376 element.remove();377 return editor.destroy();378 } );379 } );380 it( 'should focus view after command execution', () => {381 const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );382 dropdown.listView.items.first.children.first.fire( 'execute' );383 sinon.assert.calledOnce( focusSpy );384 } );385 it( 'executes command when it\'s executed', () => {386 const spy = sinon.stub( editor, 'execute' );387 dropdown.listView.items.first.children.first.fire( 'execute' );388 expect( spy.calledOnce ).to.be.true;389 expect( spy.args[ 0 ][ 0 ] ).to.equal( 'mergeTableCellUp' );390 } );391 } );...

Full Screen

Full Screen

enabled_states_test.js

Source:enabled_states_test.js Github

copy

Full Screen

1// ==========================================================================2// Project: SproutCore - JavaScript Application Framework3// Copyright: ©2006-2011 Strobe Inc. and contributors.4// ©2008-2011 Apple Inc. All rights reserved.5// License: Licensed under MIT license (see license.js)6// ==========================================================================7/*global module test equals ok */8var parent, view, child;9/** Test the SC.View states. */10module("SC.View#enabledState", {11 setup: function () {12 child = SC.View.create();13 view = SC.View.create({ childViews: [child] });14 parent = SC.View.create({ childViews: [view] });15 },16 teardown: function () {17 parent.destroy();18 parent = view = child = null;19 }20});21/**22 Test the initial state.23 */24test("Test initial states.", function () {25 // Test expected state of the views.26 equals(parent.enabledState, SC.CoreView.ENABLED, "A regular parent view should be in the state");27 equals(view.enabledState, SC.CoreView.ENABLED, "A regular view should be in the state");28 equals(child.enabledState, SC.CoreView.ENABLED, "A regular child view should be in the state");29 ok(parent.get('isEnabled'), "isEnabled should be true");30 ok(parent.get('isEnabledInPane'), "isEnabledInPane should be true");31 ok(view.get('isEnabled'), "isEnabled should be true");32 ok(view.get('isEnabledInPane'), "isEnabledInPane should be true");33 ok(child.get('isEnabled'), "isEnabled should be true");34 ok(child.get('isEnabledInPane'), "isEnabledInPane should be true");35});36/**37 Test changing isEnabled to false on the child.38 */39test("Test toggling isEnabled on child.", function () {40 SC.run(function () {41 child.set('isEnabled', false);42 });43 // Test expected state of the views.44 SC.run(function () {45 equals(parent.enabledState, SC.CoreView.ENABLED, "A regular parent view should be in the state");46 equals(view.enabledState, SC.CoreView.ENABLED, "A regular view should be in the state");47 equals(child.enabledState, SC.CoreView.DISABLED, "A disabled child view should be in the state");48 ok(parent.get('isEnabled'), "isEnabled should be true");49 ok(parent.get('isEnabledInPane'), "isEnabledInPane should be true");50 ok(view.get('isEnabled'), "isEnabled should be true");51 ok(view.get('isEnabledInPane'), "isEnabledInPane should be true");52 ok(!child.get('isEnabled'), "isEnabled should be false");53 ok(!child.get('isEnabledInPane'), "isEnabledInPane should be false");54 });55});56/**57 Test changing isEnabled to false on the view.58 */59test("Test toggling isEnabled on view.", function () {60 SC.run(function () {61 view.set('isEnabled', false);62 });63 // Test expected state of the views.64 SC.run(function () {65 equals(parent.enabledState, SC.CoreView.ENABLED, "A regular parent view should be in the state");66 equals(view.enabledState, SC.CoreView.DISABLED, "A disabled view should be in the state");67 equals(child.enabledState, SC.CoreView.DISABLED_BY_PARENT, "A regular child view with disabled ancestor should be in the state");68 ok(parent.get('isEnabled'), "isEnabled should be true");69 ok(parent.get('isEnabledInPane'), "isEnabledInPane should be true");70 ok(!view.get('isEnabled'), "isEnabled should be false");71 ok(!view.get('isEnabledInPane'), "isEnabledInPane should be false");72 ok(child.get('isEnabled'), "isEnabled should be true");73 ok(!child.get('isEnabledInPane'), "isEnabledInPane should be false");74 });75 SC.run(function () {76 child.set('isEnabled', false);77 });78 // Test expected state of the views.79 SC.run(function () {80 equals(parent.enabledState, SC.CoreView.ENABLED, "A regular parent view should be in the state");81 equals(view.enabledState, SC.CoreView.DISABLED, "A disabled view should be in the state");82 equals(child.enabledState, SC.CoreView.DISABLED, "A disabled child view with disabled ancestor should be in the state");83 ok(parent.get('isEnabled'), "isEnabled should be true");84 ok(parent.get('isEnabledInPane'), "isEnabledInPane should be true");85 ok(!view.get('isEnabled'), "isEnabled should be false");86 ok(!view.get('isEnabledInPane'), "isEnabledInPane should be false");87 ok(!child.get('isEnabled'), "isEnabled should be true");88 ok(!child.get('isEnabledInPane'), "isEnabledInPane should be false");89 });90 SC.run(function () {91 view.set('isEnabled', true);92 });93 // Test expected state of the views.94 SC.run(function () {95 equals(parent.enabledState, SC.CoreView.ENABLED, "A regular parent view should be in the state");96 equals(view.enabledState, SC.CoreView.ENABLED, "A regular view should be in the state");97 equals(child.enabledState, SC.CoreView.DISABLED, "A disabled child view should be in the state");98 ok(parent.get('isEnabled'), "isEnabled should be true");99 ok(parent.get('isEnabledInPane'), "isEnabledInPane should be true");100 ok(view.get('isEnabled'), "isEnabled should be false");101 ok(view.get('isEnabledInPane'), "isEnabledInPane should be false");102 ok(!child.get('isEnabled'), "isEnabled should be true");103 ok(!child.get('isEnabledInPane'), "isEnabledInPane should be false");104 });105});106/**107 Test changing isEnabled to false on the view.108 */109test("Test toggling isEnabled on parent.", function () {110 SC.run(function () {111 parent.set('isEnabled', false);112 });113 // Test expected state of the views.114 SC.run(function () {115 equals(parent.enabledState, SC.CoreView.DISABLED, "A disabled parent view should be in the state");116 equals(view.enabledState, SC.CoreView.DISABLED_BY_PARENT, "A regular view with disabled parent should be in the state");117 equals(child.enabledState, SC.CoreView.DISABLED_BY_PARENT, "A regular child view with disabled ancestor should be in the state");118 ok(!parent.get('isEnabled'), "disabled parent isEnabled should be false");119 ok(!parent.get('isEnabledInPane'), "disabled parent isEnabledInPane should be false");120 ok(view.get('isEnabled'), "view isEnabled should be true");121 ok(!view.get('isEnabledInPane'), "view isEnabledInPane should be false");122 ok(child.get('isEnabled'), "child isEnabled should be true");123 ok(!child.get('isEnabledInPane'), "child isEnabledInPane should be false");124 });125 SC.run(function () {126 child.set('isEnabled', false);127 });128 // Test expected state of the views.129 SC.run(function () {130 equals(parent.enabledState, SC.CoreView.DISABLED, "A disabled parent view should be in the state");131 equals(view.enabledState, SC.CoreView.DISABLED_BY_PARENT, "A regular view with disabled parent should be in the state");132 equals(child.enabledState, SC.CoreView.DISABLED, "A disabled child view with disabled ancestor should be in the state");133 ok(!parent.get('isEnabled'), "isEnabled should be false");134 ok(!parent.get('isEnabledInPane'), "isEnabledInPane should be false");135 ok(view.get('isEnabled'), "view isEnabled should be true");136 ok(!view.get('isEnabledInPane'), "view isEnabledInPane should be false");137 ok(!child.get('isEnabled'), "disabled child isEnabled should be false");138 ok(!child.get('isEnabledInPane'), "disabled child isEnabledInPane should be false");139 });140 SC.run(function () {141 parent.set('isEnabled', true);142 });143 // Test expected state of the views.144 SC.run(function () {145 equals(parent.enabledState, SC.CoreView.ENABLED, "A regular parent view should be in the state");146 equals(view.enabledState, SC.CoreView.ENABLED, "A regular view should be in the state");147 equals(child.enabledState, SC.CoreView.DISABLED, "A disabled child view should be in the state");148 ok(parent.get('isEnabled'), "isEnabled should be true");149 ok(parent.get('isEnabledInPane'), "isEnabledInPane should be true");150 ok(view.get('isEnabled'), "isEnabled should be true");151 ok(view.get('isEnabledInPane'), "isEnabledInPane should be true");152 ok(!child.get('isEnabled'), "disabled child isEnabled should be false");153 ok(!child.get('isEnabledInPane'), "disabled child isEnabledInPane should be false");154 });155});156/**157 Test changing isEnabled to false on the view.158 */159test("Test toggling isEnabled on view.", function () {160 SC.run(function () {161 view.set('isEnabled', false);162 });163 // Test expected state of the views.164 SC.run(function () {165 equals(parent.enabledState, SC.CoreView.ENABLED, "A regular parent view should be in the state");166 equals(view.enabledState, SC.CoreView.DISABLED, "A disabled view should be in the state");167 equals(child.enabledState, SC.CoreView.DISABLED_BY_PARENT, "A regular child view with disabled ancestor should be in the state");168 ok(parent.get('isEnabled'), "isEnabled should be true");169 ok(parent.get('isEnabledInPane'), "isEnabledInPane should be true");170 ok(!view.get('isEnabled'), "isEnabled should be false");171 ok(!view.get('isEnabledInPane'), "isEnabledInPane should be false");172 ok(child.get('isEnabled'), "isEnabled should be true");173 ok(!child.get('isEnabledInPane'), "isEnabledInPane should be false");174 });175 SC.run(function () {176 child.set('isEnabled', false);177 });178 // Test expected state of the views.179 SC.run(function () {180 equals(parent.enabledState, SC.CoreView.ENABLED, "A regular parent view should be in the state");181 equals(view.enabledState, SC.CoreView.DISABLED, "A disabled view should be in the state");182 equals(child.enabledState, SC.CoreView.DISABLED, "A disabled child view with disabled ancestor should be in the state");183 ok(parent.get('isEnabled'), "isEnabled should be true");184 ok(parent.get('isEnabledInPane'), "isEnabledInPane should be true");185 ok(!view.get('isEnabled'), "isEnabled should be false");186 ok(!view.get('isEnabledInPane'), "isEnabledInPane should be false");187 ok(!child.get('isEnabled'), "isEnabled should be true");188 ok(!child.get('isEnabledInPane'), "isEnabledInPane should be false");189 });190 SC.run(function () {191 view.set('isEnabled', true);192 });193 // Test expected state of the views.194 SC.run(function () {195 equals(parent.enabledState, SC.CoreView.ENABLED, "A regular parent view should be in the state");196 equals(view.enabledState, SC.CoreView.ENABLED, "A regular view should be in the state");197 equals(child.enabledState, SC.CoreView.DISABLED, "A disabled child view should be in the state");198 ok(parent.get('isEnabled'), "isEnabled should be true");199 ok(parent.get('isEnabledInPane'), "isEnabledInPane should be true");200 ok(view.get('isEnabled'), "isEnabled should be false");201 ok(view.get('isEnabledInPane'), "isEnabledInPane should be false");202 ok(!child.get('isEnabled'), "isEnabled should be true");203 ok(!child.get('isEnabledInPane'), "isEnabledInPane should be false");204 });205});206/**207 Test changing isEnabled to false on the view.208 */209test("Test shouldInheritEnabled.", function () {210 SC.run(function () {211 view.set('shouldInheritEnabled', false);212 parent.set('isEnabled', false);213 });214 // Test expected state of the views.215 SC.run(function () {216 equals(parent.enabledState, SC.CoreView.DISABLED, "A disabled parent view should be in the state");217 equals(view.enabledState, SC.CoreView.ENABLED, "A regular view with shouldInheritEnabled with disabled parent should be in the state");218 equals(child.enabledState, SC.CoreView.ENABLED, "A regular child view should be in the state");219 });220 SC.run(function () {221 view.set('isEnabled', false);222 });223 // Test expected state of the views.224 SC.run(function () {225 equals(parent.enabledState, SC.CoreView.DISABLED, "A disabled parent view should be in the state");226 equals(view.enabledState, SC.CoreView.DISABLED, "A disabled view with shouldInheritEnabled and disabled parent should be in the state");227 equals(child.enabledState, SC.CoreView.DISABLED_BY_PARENT, "A regular child view with disabled ancestor should be in the state");228 });229 SC.run(function () {230 parent.set('isEnabled', true);231 });232 // Test expected state of the views.233 SC.run(function () {234 equals(parent.enabledState, SC.CoreView.ENABLED, "A regular parent view should be in the state");235 equals(view.enabledState, SC.CoreView.DISABLED, "A disabled view should be in the state");236 equals(child.enabledState, SC.CoreView.DISABLED_BY_PARENT, "A regular child view with disabled ancestor should be in the state");237 });238});239test("Test toggling isEnabled adds/removes disabled class.", function () {240 parent.createLayer();241 parent._doAttach(document.body);242 ok(!parent.$().hasClass('disabled'), "A regular parent should not have disabled class.");243 SC.run(function () {244 parent.set('isEnabled', false);245 });246 // Test expected state of the views.247 SC.run(function () {248 ok(parent.$().hasClass('disabled'), "A disabled parent should have disabled class.");249 });250 SC.run(function () {251 parent.set('isEnabled', true);252 });253 // Test expected state of the views.254 SC.run(function () {255 ok(!parent.$().hasClass('disabled'), "A re-enabled parent should not have disabled class.");256 });257 parent._doDetach();258 parent.destroyLayer();259});260test("Test optimized display update.", function () {261 SC.run(function () {262 parent.set('isEnabled', false);263 });264 parent.createLayer();265 parent._doAttach(document.body);266 // Test expected state of the views.267 SC.run(function () {268 ok(parent.$().hasClass('disabled'), "A disabled when attached parent should have disabled class.");269 });270 parent._doDetach();271 parent.destroyLayer();272 parent.createLayer();273 parent._doAttach(document.body);274 SC.run(function () {275 parent.set('isEnabled', true);276 });277 // Test expected state of the views.278 SC.run(function () {279 ok(!parent.$().hasClass('disabled'), "A re-enabled parent should not have disabled class.");280 });281 parent._doDetach();282 parent.destroyLayer();283});284test("initializing with isEnabled: false, should still add the proper class on append", function() {285 var newView = SC.View.create({286 isEnabled: false287 });288 parent.createLayer();289 parent._doAttach(document.body);290 parent.appendChild(newView);291 ok(newView.$().hasClass('disabled'), "An initialized as disabled view should have disabled class on append.");...

Full Screen

Full Screen

command.js

Source:command.js Github

copy

Full Screen

1/**2 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license4 */5import Command from '../src/command';6import ModelTestEditor from './_utils/modeltesteditor';7describe( 'Command', () => {8 let editor, command;9 beforeEach( () => {10 return ModelTestEditor11 .create()12 .then( newEditor => {13 editor = newEditor;14 command = new Command( editor );15 } );16 } );17 afterEach( () => {18 command.destroy();19 return editor.destroy();20 } );21 describe( 'constructor()', () => {22 it( 'sets the editor property', () => {23 expect( command.editor ).to.equal( editor );24 } );25 it( 'sets the state properties', () => {26 expect( command.value ).to.be.undefined;27 expect( command.isEnabled ).to.be.false;28 } );29 it( 'sets the affectsData property', () => {30 expect( command ).to.have.property( 'affectsData', true );31 } );32 it( 'adds a listener which refreshes the command on editor.model.Document#event:change', () => {33 sinon.spy( command, 'refresh' );34 editor.model.document.fire( 'change' );35 expect( command.refresh.calledOnce ).to.be.true;36 } );37 } );38 describe( 'value', () => {39 it( 'fires change event', () => {40 const spy = sinon.spy();41 command.on( 'change:value', spy );42 command.value = 1;43 expect( spy.calledOnce ).to.be.true;44 } );45 } );46 describe( 'isEnabled', () => {47 it( 'fires change event', () => {48 const spy = sinon.spy();49 command.on( 'change:isEnabled', spy );50 command.isEnabled = true;51 expect( spy.calledOnce ).to.be.true;52 } );53 it( 'is falsy when the editor is in read-only mode and command affects data', () => {54 command.affectsData = true;55 editor.isReadOnly = false;56 command.isEnabled = true;57 editor.isReadOnly = true;58 // Is false.59 expect( command.isEnabled ).to.false;60 command.refresh();61 // Still false.62 expect( command.isEnabled ).to.false;63 editor.isReadOnly = false;64 // And is back to true.65 expect( command.isEnabled ).to.true;66 } );67 it( 'doesn\'t depend on the editor read-only mode when command doesn\'t affect data', () => {68 command.affectsData = false;69 editor.isReadOnly = false;70 command.isEnabled = true;71 editor.isReadOnly = true;72 // Is true.73 expect( command.isEnabled ).to.true;74 command.refresh();75 // Still true.76 expect( command.isEnabled ).to.true;77 editor.isReadOnly = false;78 // And is back to true.79 expect( command.isEnabled ).to.true;80 } );81 it( 'is observable when is overridden', () => {82 editor.isReadOnly = false;83 command.isEnabled = true;84 editor.bind( 'something' ).to( command, 'isEnabled' );85 expect( editor.something ).to.true;86 editor.isReadOnly = true;87 expect( editor.something ).to.false;88 } );89 it( 'stops `set` event to force disabled and not affect `change` event', () => {90 const setSpy = sinon.spy();91 const changeSpy = sinon.spy();92 command.isEnabled = true;93 editor.isReadOnly = false;94 command.on( 'set', setSpy );95 command.on( 'change', changeSpy );96 editor.isReadOnly = true;97 sinon.assert.notCalled( setSpy );98 sinon.assert.calledOnce( changeSpy );99 } );100 } );101 describe( 'execute()', () => {102 it( 'is decorated', () => {103 const spy = sinon.spy();104 command.on( 'execute', spy );105 command.isEnabled = true;106 command.execute( 1, 2 );107 expect( spy.calledOnce ).to.be.true;108 expect( spy.args[ 0 ][ 1 ] ).to.deep.equal( [ 1, 2 ] );109 } );110 it( 'is automatically blocked (with low priority listener) if command is disabled', () => {111 const spyExecute = sinon.spy();112 const spyHighest = sinon.spy();113 const spyHigh = sinon.spy();114 class SpyCommand extends Command {115 execute() {116 spyExecute();117 }118 }119 const command = new SpyCommand( editor );120 command.on( 'execute', spyHighest, { priority: 'highest' } );121 command.on( 'execute', spyHigh, { priority: 'high' } );122 command.execute();123 expect( spyExecute.called ).to.be.false;124 expect( spyHighest.calledOnce ).to.be.true;125 expect( spyHigh.called ).to.be.false;126 } );127 } );128 describe( 'refresh()', () => {129 it( 'sets isEnabled to true', () => {130 command.refresh();131 expect( command.isEnabled ).to.be.true;132 } );133 // This is an acceptance test for the ability to override a command's state from outside134 // in a way that at any moment the action can be reverted by just offing the listener and135 // refreshing the command once again.136 it( 'is safely overridable using change:isEnabled', () => {137 command.on( 'change:isEnabled', callback, { priority: 'high' } );138 command.isEnabled = false;139 command.refresh();140 expect( command.isEnabled ).to.be.false;141 command.off( 'change:isEnabled', callback );142 command.refresh();143 expect( command.isEnabled ).to.be.true;144 function callback( evt ) {145 command.isEnabled = false;146 evt.stop();147 }148 } );149 } );150 describe( 'forceDisabled() / clearForceDisabled()', () => {151 it( 'forceDisabled() should disable the command', () => {152 command.forceDisabled( 'foo' );153 command.isEnabled = true;154 expect( command.isEnabled ).to.be.false;155 } );156 it( 'clearForceDisabled() should enable the command', () => {157 command.forceDisabled( 'foo' );158 command.clearForceDisabled( 'foo' );159 expect( command.isEnabled ).to.be.true;160 } );161 it( 'clearForceDisabled() used with wrong identifier should not enable the command', () => {162 command.forceDisabled( 'foo' );163 command.clearForceDisabled( 'bar' );164 command.isEnabled = true;165 expect( command.isEnabled ).to.be.false;166 } );167 it( 'using forceDisabled() twice with the same identifier should not have any effect', () => {168 command.forceDisabled( 'foo' );169 command.forceDisabled( 'foo' );170 command.clearForceDisabled( 'foo' );171 expect( command.isEnabled ).to.be.true;172 } );173 it( 'command is enabled only after all disables were cleared', () => {174 command.forceDisabled( 'foo' );175 command.forceDisabled( 'bar' );176 command.clearForceDisabled( 'foo' );177 command.isEnabled = true;178 expect( command.isEnabled ).to.be.false;179 command.clearForceDisabled( 'bar' );180 expect( command.isEnabled ).to.be.true;181 } );182 it( 'command should remain disabled if isEnabled has a callback disabling it', () => {183 command.on( 'set:isEnabled', evt => {184 evt.return = false;185 evt.stop();186 } );187 command.forceDisabled( 'foo' );188 command.clearForceDisabled( 'foo' );189 command.isEnabled = true;190 expect( command.isEnabled ).to.be.false;191 } );192 } );...

Full Screen

Full Screen

StringValidators.test.js

Source:StringValidators.test.js Github

copy

Full Screen

1import { expect } from '@open-wc/testing';2import {3 IsString,4 EqualsLength,5 MinLength,6 MaxLength,7 MinMaxLength,8 IsEmail,9 Pattern,10} from '../../src/validate/validators/StringValidators.js';11describe('String Validation', () => {12 it('provides new IsString() to allow only strings', () => {13 let isEnabled;14 const validator = new IsString();15 expect(IsString.validatorName).to.equal('IsString');16 isEnabled = validator.execute('foo');17 expect(isEnabled).to.be.false;18 isEnabled = validator.execute(NaN);19 expect(validator.execute(NaN)).to.be.true;20 isEnabled = validator.execute(4);21 expect(validator.execute(4)).to.be.true;22 });23 it('provides new EqualsLength(x) to allow only a specific string length', () => {24 let isEnabled;25 const validator = new EqualsLength(3);26 expect(EqualsLength.validatorName).to.equal('EqualsLength');27 isEnabled = validator.execute('foo');28 expect(isEnabled).to.be.false;29 isEnabled = validator.execute('fo');30 expect(isEnabled).to.be.true;31 isEnabled = validator.execute('foobar');32 expect(isEnabled).to.be.true;33 });34 it('provides new MinLength(x) to allow only strings longer then min', () => {35 let isEnabled;36 const validator = new MinLength(3);37 expect(MinLength.validatorName).to.equal('MinLength');38 isEnabled = validator.execute('foo');39 expect(isEnabled).to.be.false;40 isEnabled = validator.execute('fo');41 expect(isEnabled).to.be.true;42 });43 it('provides new MaxLength(x) to allow only strings shorter then max', () => {44 let isEnabled;45 const validator = new MaxLength(3);46 expect(MaxLength.validatorName).to.equal('MaxLength');47 isEnabled = validator.execute('foo');48 expect(isEnabled).to.be.false;49 isEnabled = validator.execute('foobar');50 expect(isEnabled).to.be.true;51 });52 it('provides new MinMaxValidator({ min: x, max: y}) to allow only strings between min and max', () => {53 let isEnabled;54 const validator = new MinMaxLength({ min: 2, max: 4 });55 expect(MinMaxLength.validatorName).to.equal('MinMaxLength');56 isEnabled = validator.execute('foo');57 expect(isEnabled).to.be.false;58 isEnabled = validator.execute('f');59 expect(isEnabled).to.be.true;60 isEnabled = validator.execute('foobar');61 expect(isEnabled).to.be.true;62 });63 it('provides new IsEmail() to allow only valid email formats', () => {64 let isEnabled;65 const validator = new IsEmail();66 expect(IsEmail.validatorName).to.equal('IsEmail');67 isEnabled = validator.execute('foo@bar.com');68 expect(isEnabled).to.be.false;69 isEnabled = validator.execute('name!#$%*@bar.com');70 expect(isEnabled).to.be.false;71 isEnabled = validator.execute('foo');72 expect(isEnabled).to.be.true;73 isEnabled = validator.execute('foo@');74 expect(isEnabled).to.be.true;75 isEnabled = validator.execute('bar.com');76 expect(isEnabled).to.be.true;77 isEnabled = validator.execute('@bar.com');78 expect(isEnabled).to.be.true;79 isEnabled = validator.execute('foo@bar@example.com');80 expect(isEnabled).to.be.true;81 isEnabled = validator.execute('foo@bar');82 expect(isEnabled).to.be.true;83 isEnabled = validator.execute('foo@120.120.120.93');84 expect(isEnabled).to.be.true;85 });86 it('provides new Pattern() to allow only valid patterns', () => {87 let isEnabled;88 let validator = new Pattern(/#LionRocks/);89 expect(Pattern.validatorName).to.equal('Pattern');90 isEnabled = validator.execute('#LionRocks');91 expect(isEnabled).to.be.false;92 isEnabled = validator.execute('#LionRests');93 expect(isEnabled).to.be.true;94 validator = new Pattern(new RegExp('#LionRocks'));95 isEnabled = validator.execute('Some string #LionRocks');96 expect(isEnabled).to.be.false;97 validator = new Pattern('#LionRocks');98 expect(() => {99 validator.execute('Some string #LionRocks');100 }).to.throw(101 'Psst... Pattern validator expects RegExp object as parameter e.g, new Pattern(/#LionRocks/) or new Pattern(RegExp("#LionRocks")',102 );103 });...

Full Screen

Full Screen

DateValidators.test.js

Source:DateValidators.test.js Github

copy

Full Screen

1import { expect } from '@open-wc/testing';2import { normalizeDateTime } from '@lion/localize';3import {4 IsDate,5 MinDate,6 MaxDate,7 MinMaxDate,8 IsDateDisabled,9} from '../../src/validate/validators/DateValidators.js';10describe('Date Validation', () => {11 it('provides new isDate() to allow only dates', () => {12 let isEnabled;13 const validator = new IsDate();14 expect(IsDate.validatorName).to.equal('IsDate');15 isEnabled = validator.execute(new Date());16 expect(isEnabled).to.be.false;17 isEnabled = validator.execute('foo');18 expect(isEnabled).to.be.true;19 isEnabled = validator.execute(4);20 expect(isEnabled).to.be.true;21 });22 it('provides new minDate(x) to allow only dates after min', () => {23 let isEnabled;24 const validator = new MinDate(new Date('2018/02/02'));25 expect(MinDate.validatorName).to.equal('MinDate');26 isEnabled = validator.execute(new Date('2018-02-03'));27 expect(isEnabled).to.be.false;28 isEnabled = validator.execute(new Date('2018-02-01'));29 expect(isEnabled).to.be.true;30 isEnabled = validator.execute(new Date('2018/02/02 10:00:00'));31 expect(isEnabled).to.be.false;32 const today = new Date();33 const todayFormatted = normalizeDateTime(today);34 const todayValidator = new MinDate(today);35 isEnabled = todayValidator.execute(todayFormatted);36 expect(isEnabled).to.be.false;37 });38 it('provides maxDate() to allow only dates before max', () => {39 let isEnabled;40 const validator = new MaxDate(new Date('2018/02/02'));41 expect(MaxDate.validatorName).to.equal('MaxDate');42 isEnabled = validator.execute(new Date('2018-02-01'));43 expect(isEnabled).to.be.false;44 isEnabled = validator.execute(new Date('2018/02/02 10:00:00'));45 expect(isEnabled).to.be.false;46 isEnabled = validator.execute(new Date('2018-02-03'));47 expect(isEnabled).to.be.true;48 const today = new Date();49 const todayFormatted = normalizeDateTime(today);50 const todayValidator = new MaxDate(today);51 isEnabled = todayValidator.execute(todayFormatted);52 expect(isEnabled).to.be.false;53 });54 it('provides new MinMaxDate() to allow only dates between min and max', () => {55 let isEnabled;56 const validator = new MinMaxDate({57 min: new Date('2018/02/02'),58 max: new Date('2018/02/04'),59 });60 expect(MinMaxDate.validatorName).to.equal('MinMaxDate');61 isEnabled = validator.execute(new Date('2018/02/03'));62 expect(isEnabled).to.be.false;63 isEnabled = validator.execute(new Date('2018/02/01'));64 expect(isEnabled).to.be.true;65 isEnabled = validator.execute(new Date('2018/02/05'));66 expect(isEnabled).to.be.true;67 isEnabled = validator.execute(new Date('2018/02/02 10:00:00'));68 expect(isEnabled).to.be.false;69 isEnabled = validator.execute(new Date('2018/02/04 10:00:00'));70 expect(isEnabled).to.be.false;71 const today = new Date();72 const todayFormatted = normalizeDateTime(today);73 const todayValidator = new MinMaxDate({ min: today, max: today });74 isEnabled = todayValidator.execute(todayFormatted);75 expect(isEnabled).to.be.false;76 });77 it('provides new IsDateDisabled() to disable dates matching specified condition', () => {78 let isDisabled;79 const validator = new IsDateDisabled(/** @param {Date} d */ d => d.getDate() === 3);80 expect(IsDateDisabled.validatorName).to.equal('IsDateDisabled');81 isDisabled = validator.execute(new Date('2018/02/04'));82 expect(isDisabled).to.be.false;83 isDisabled = validator.execute(new Date('2018/02/03'));84 expect(isDisabled).to.be.true;85 });...

Full Screen

Full Screen

widget-toggle.js

Source:widget-toggle.js Github

copy

Full Screen

1/*! tablesorter enable/disable sort & filter (BETA) - 11/10/2015 (v2.24.4)2 * Requires tablesorter v2.24.4+ & jQuery 1.7+3 * by Rob Garrison4 */5;( function( $ ) {6 'use strict';7 var ts = $.tablesorter,8 tst = ts.toggleTS = {9 init : function( c, wo ) {10 wo.toggleTS_isEnabled = true; // enabled11 wo.toggleTS_areDisabled = {12 headers : [],13 filters : []14 };15 c.$table.on('enable.toggleTS disable.toggleTS', function( event ) {16 tst.toggle( this.config, this.config.widgetOptions, event.type === 'enable' );17 });18 },19 toggle : function( c, wo, isEnabled ) {20 if ( wo.toggleTS_isEnabled !== isEnabled ) {21 wo.toggleTS_isEnabled = isEnabled;22 var indx, $el,23 len = c.$headers.length;24 // table headers25 for ( indx = 0; indx < len; indx++ ) {26 $el = c.$headers.eq( indx );27 // function added in v2.24.428 ts.setColumnSort( c, $el, !isEnabled );29 // function added in v2.24.4; passing "isEnabled" allows removal of "next sort" labels30 ts.setColumnAriaLabel( c, $el, isEnabled );31 }32 if ( wo.toggleTS_hideFilterRow ) {33 c.$table.find( '.' + ts.css.filterRow ).toggle( isEnabled );34 } else if ( ts.hasWidget( c.$table, 'filter' ) ) {35 // c.$filters points to filter CELL36 len = c.$filters.length;37 for ( indx = 0; indx < len; indx++ ) {38 if ( isEnabled && !wo.toggleTS_areDisabled.filters[ indx ] ) {39 c.$filters.eq( indx ).find( 'input, select' )40 .removeClass( ts.css.filterDisabled )41 .prop( 'disabled', false );42 } else if ( !isEnabled ) {43 $el = c.$filters.eq( indx ).find( 'input, select' );44 if ( $el.hasClass( ts.css.filterDisabled ) ) {45 wo.toggleTS_areDisabled.filters[ indx ] = true;46 }47 $el48 .addClass( ts.css.filterDisabled )49 .prop( 'disabled', true );50 }51 }52 }53 // include external filters54 wo.filter_$externalFilters55 .toggleClass( ts.css.filterDisabled, isEnabled )56 .prop( 'disabled', !isEnabled );57 }58 if ( typeof wo.toggleTS_callback === 'function' ) {59 wo.toggleTS_callback( c, isEnabled );60 }61 }62 };63 ts.addWidget({64 id: 'toggle-ts',65 options: {66 toggleTS_hideFilterRow : false,67 toggleTS_callback : null68 },69 init : function( table, thisWidget, c, wo ) {70 tst.init( c, wo );71 },72 remove : function( table, c ) {73 c.$table.off( 'enable.toggleTS disable.toggleTS' );74 }75 });...

Full Screen

Full Screen

App.js

Source:App.js Github

copy

Full Screen

1import Card from "./card";2export default function App(){3 let tableData=[4 {5 plan:"FREE",6 currency:"$",7 price: 0,8 period: "month",9 offers:[10 {name: "Single User",11 isEnabled: true12 },13 {name: "5GB Storage",14 isEnabled: true15 },16 {name: "Unlimited Public Projects",17 isEnabled: true18 },19 {name: "Community Accesss",20 isEnabled: true21 },22 {name: "Unlimited Private Projects",23 isEnabled: false24 },25 {name: "Dedicated Phone Support",26 isEnabled: false27 },28 {name: "Free Subdomain",29 isEnabled: false30 },31 {name: "Monthly Status Reports",32 isEnabled: false33 },34 ] 35 },36 {37 plan:"PLUS",38 currency:"$",39 price: 9,40 period: "month",41 offers:[42 {name: "5 Users",43 isEnabled: true},44 {name: "5oGB Storage",45 isEnabled: true},46 {name: "Unlimited Public Projects",47 isEnabled: true},48 {name: "Community Accesss",49 isEnabled:true},50 {name: "Unlimited Private Projects",51 isEnabled: true},52 {name: "Dedicated Phone Support",53 isEnabled: true},54 {name: "Free Subdomain",55 isEnabled: true},56 {name: "Monthly Status Reports",57 isEnabled: false},58 ] 59 },60 {61 plan:"PRO",62 currency:"$",63 price: 49,64 period: "month",65 offers:[66 {name: "Unlimited Users",67 isEnabled: true},68 {name: "150GB Storage",69 isEnabled: true},70 {name: "Unlimited Public Projects",71 isEnabled: true72 },73 {name: "Community Accesss",74 isEnabled:true75 },76 {name: "Unlimited Private Projects",77 isEnabled: true78 },79 {name: "Dedicated Phone Support",80 isEnabled: true81 },82 {name: "Free Subdomain",83 isEnabled:true84 },85 {name: "Monthly Status Reports",86 isEnabled: true},87 ] 88 },89 ]90 return <>91 <section class="pricing py-5">92 <div class="container">93 <div class="row">94 {95 tableData.map((obj)=>{96 return <Card data={obj}></Card>97 })98 }99 </div>100 </div>101 </section>102 </>...

Full Screen

Full Screen

NumberValidators.test.js

Source:NumberValidators.test.js Github

copy

Full Screen

1import { expect } from '@open-wc/testing';2import {3 IsNumber,4 MinNumber,5 MaxNumber,6 MinMaxNumber,7} from '../../src/validate/validators/NumberValidators.js';8describe('Number Validation', () => {9 it('provides new IsNumber() to allow only numbers', () => {10 let isEnabled;11 const validator = new IsNumber();12 expect(IsNumber.validatorName).to.equal('IsNumber');13 isEnabled = validator.execute(4);14 expect(isEnabled).to.be.false;15 isEnabled = validator.execute(NaN);16 expect(isEnabled).to.be.true;17 isEnabled = validator.execute('4');18 expect(isEnabled).to.be.true;19 });20 it('provides new MinNumber(x) to allow only numbers longer then min', () => {21 let isEnabled;22 const validator = new MinNumber(3);23 expect(MinNumber.validatorName).to.equal('MinNumber');24 isEnabled = validator.execute(3);25 expect(isEnabled).to.be.false;26 isEnabled = validator.execute(2);27 expect(isEnabled).to.be.true;28 });29 it('provides new MaxNumber(x) to allow only number shorter then max', () => {30 let isEnabled;31 const validator = new MaxNumber(3);32 expect(MaxNumber.validatorName).to.equal('MaxNumber');33 isEnabled = validator.execute(3);34 expect(isEnabled).to.be.false;35 isEnabled = validator.execute(4);36 expect(isEnabled).to.be.true;37 });38 it('provides new MinMaxNumber({ min: x, max: y}) to allow only numbers between min and max', () => {39 let isEnabled;40 const validator = new MinMaxNumber({ min: 2, max: 4 });41 expect(MinMaxNumber.validatorName).to.equal('MinMaxNumber');42 isEnabled = validator.execute(2);43 expect(isEnabled).to.be.false;44 isEnabled = validator.execute(4);45 expect(isEnabled).to.be.false;46 isEnabled = validator.execute(1);47 expect(isEnabled).to.be.true;48 isEnabled = validator.execute(5);49 expect(isEnabled).to.be.true;50 });...

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 context = await browser.newContext();5 const page = await context.newPage();6 const isDisabled = await page.isEnabled('input[type="submit"]');7 console.log("isDisabled: ", isDisabled);8 await browser.close();9})();10Example 2: isEnabled() method with a selector of disabled input11const {chromium} = require('playwright');12(async () => {13 const browser = await chromium.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 const isDisabled = await page.isEnabled('input[type="submit"][disabled]');17 console.log("isDisabled: ", isDisabled);18 await browser.close();19})();20Example 3: isEnabled() method with a selector of enabled input21const {chromium} = require('playwright');22(async () => {23 const browser = await chromium.launch();24 const context = await browser.newContext();25 const page = await context.newPage();26 const isDisabled = await page.isEnabled('input[type="submit"]:not([disabled])');27 console.log("isDisabled: ", isDisabled);28 await browser.close();29})();30Example 4: isEnabled() method with a selector of disabled button31const {chromium} = require('playwright');32(async () => {33 const browser = await chromium.launch();34 const context = await browser.newContext();35 const page = await context.newPage();36 const isDisabled = await page.isEnabled('button[type="submit"][disabled]');37 console.log("isDisabled: ", isDisabled);38 await browser.close();39})();40Example 5: isEnabled() method with a selector of enabled button

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const isEnabled = await page.isEnabled('input[name="q"]');7 console.log(isEnabled);8 await browser.close();9})();10How to use isEnabled() method?11isEnabled() is a method of the ElementHandle class. We can use it as follows:12const isEnabled = await page.isEnabled(selector);13How to use isDisabled() method?14isDisabled() is a method of the ElementHandle class. We can use it as follows:15const isDisabled = await page.isDisabled(selector);16How to use isEnabled() method?17isEnabled() is a method of the ElementHandle class. We can use it as follows:18const isEnabled = await page.isEnabled(selector);19How to use isEditable() method?20isEditable() is a method of the ElementHandle class. We can use it as follows:21const isEditable = await page.isEditable(selector);22How to use isEnabled() method?23isEnabled() is a method of the ElementHandle class. We can use it as follows:24const isEnabled = await page.isEnabled(selector);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isEnabled } = require('playwright/lib/server/chromium/crNetworkManager');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 console.log(enabled);8 await browser.close();9})();10const { enableRequestInterception } = require('playwright/lib/server/chromium/crNetworkManager');11const { chromium } = require('playwright');12(async () => {13 const browser = await chromium.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 console.log(enabled);17 await browser.close();18})();19const { disableRequestInterception } = require('playwright/lib/server/chromium/crNetworkManager');20const { chromium } = require('playwright');21(async () => {22 const browser = await chromium.launch();23 const context = await browser.newContext();24 const page = await context.newPage();25 console.log(enabled);26 await browser.close();27})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isEnabled } = require('playwright/lib/server/chromium/crNetworkManager');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.route('**/*', route => {8 console.log(isEnabled(route.request()));9 route.continue();10 });11 await browser.close();12})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isEnabled } = require('@playwright/test/lib/server/chromium/crBrowser');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch({ headless: false });5 const page = await browser.newPage();6 const element = await page.$('input[name="q"]');7 const enabled = await isEnabled(element);8 console.log(enabled);9 await browser.close();10})();11{12 "scripts": {13 },14 "dependencies": {15 }16}17Recommended Posts: Playwright | How to use Page.waitForSelector() method?18Playwright | How to use Page.waitForFunction() method?19Playwright | How to use Page.waitForNavigation() method?20Playwright | How to use Page.waitForResponse() method?21Playwright | How to use Page.waitForRequest() method?22Playwright | How to use Page.waitForLoadState() method?23Playwright | How to use Page.waitForEvent() method?24Playwright | How to use Page.waitForFileChooser() method?25Playwright | How to use Page.waitForDownload() method?26Playwright | How to use Page.waitFor() method?27Playwright | How to use Page.waitForTimeout() method?28Playwright | How to use Page.waitForXPath() method?

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const browser = await chromium.launch();3const page = await browser.newPage();4const isTracingEnabled = await page.context().isEnabled('tracing');5console.log(isTracingEnabled);6await browser.close();7const { chromium } = require('playwright');8const browser = await chromium.launch();9const page = await browser.newPage();10await page.context().setEnabled('tracing', false);11await browser.close();12const { chromium } = require('playwright');13const browser = await chromium.launch();14const page = await browser.newPage();15const isTracingEnabled = await page.context().isEnabled('tracing');16console.log(isTracingEnabled);17await browser.close();18const { chromium } = require('playwright');19const browser = await chromium.launch();20const page = await browser.newPage();21await page.context().setEnabled('tracing', false);22await browser.close();23const { chromium } = require('playwright');24const browser = await chromium.launch();25const page = await browser.newPage();26const isTracingEnabled = await page.context().isEnabled('tracing');27console.log(isTracingEnabled);28await browser.close();29const { chromium } = require('playwright');30const browser = await chromium.launch();31const page = await browser.newPage();32await page.context().setEnabled('tracing', false);33await browser.close();34const { chromium } = require('playwright');35const browser = await chromium.launch();36const page = await browser.newPage();37const isTracingEnabled = await page.context().isEnabled('tracing');38console.log(isTracingEnabled);39await browser.close();40const { chromium } = require('playwright');41const browser = await chromium.launch();42const page = await browser.newPage();43await page.context().setEnabled('tracing', false);44await browser.close();45const { chromium } = require('playwright');46const browser = await chromium.launch();47const page = await browser.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isEnabled } = require('playwright/lib/utils/utils');2isEnabled(element);3!isEnabled(element);4isEnabled(element);5!isEnabled(element);6const { isEnabled } = require('playwright/lib/utils/utils');7isEnabled(element);8!isEnabled(element);9isEnabled(element);10!isEnabled(element);11const { isEnabled } = require('playwright/lib/utils/utils');12isEnabled(element);13!isEnabled(element);14isEnabled(element);15!isEnabled(element);16const { isEnabled } = require('playwright/lib/utils/utils');17isEnabled(element);18!isEnabled(element);19isEnabled(element);20!isEnabled(element);21const { isEnabled } = require('playwright/lib/utils/utils');22isEnabled(element);23!isEnabled(element);24isEnabled(element);25!isEnabled(element);26const { isEnabled } = require('playwright/lib/utils/utils');27isEnabled(element);28!isEnabled(element);

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