How to use child.getAttribute method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

svg.ext.spec.js

Source:svg.ext.spec.js Github

copy

Full Screen

1import { render } from 'inferno';2import { createElement } from 'inferno-create-element';3describe('SVG (non-jsx)', () => {4 let container;5 beforeEach(function() {6 container = document.createElement('div');7 });8 afterEach(function() {9 render(null, container);10 });11 it('should set attributes correctly', () => {12 const template = val1 => createElement('svg', { height: val1 });13 render(template(null), container);14 render(template(200), container);15 expect(container.firstChild.tagName.toLowerCase()).toEqual('svg');16 expect(container.firstChild.namespaceURI).toEqual('http://www.w3.org/2000/svg');17 expect(container.firstChild.getAttribute('height')).toEqual('200');18 render(template(null), container);19 render(template(200), container);20 expect(container.firstChild.tagName.toLowerCase()).toEqual('svg');21 expect(container.firstChild.namespaceURI).toEqual('http://www.w3.org/2000/svg');22 expect(container.firstChild.getAttribute('height')).toEqual('200');23 });24 it('should respect SVG namespace and render SVG attributes', () => {25 let template;26 template = val1 =>27 createElement(28 'svg',29 {30 xmlns: 'http://www.w3.org/2000/svg',31 version: '1.1',32 baseProfile: 'full',33 width: '200',34 height: val135 },36 null37 );38 render(template(200), container);39 expect(container.firstChild.tagName.toLowerCase()).toEqual('svg');40 expect(container.firstChild.namespaceURI).toEqual('http://www.w3.org/2000/svg');41 expect(container.firstChild.getAttribute('xmlns')).toEqual('http://www.w3.org/2000/svg');42 expect(container.firstChild.getAttribute('version')).toEqual('1.1');43 expect(container.firstChild.getAttribute('baseProfile')).toEqual('full');44 expect(container.firstChild.getAttribute('width')).toEqual('200');45 render(template(null), container);46 template = () => createElement('svg', { width: 200 }, null);47 render(template(), container);48 expect(container.firstChild.tagName.toLowerCase()).toEqual('svg');49 expect(container.firstChild.namespaceURI).toEqual('http://www.w3.org/2000/svg');50 expect(container.firstChild.getAttribute('width')).toEqual('200');51 render(template(), container);52 expect(container.firstChild.tagName.toLowerCase()).toEqual('svg');53 expect(container.firstChild.namespaceURI).toEqual('http://www.w3.org/2000/svg');54 expect(container.firstChild.getAttribute('width')).toEqual('200');55 });56 it('should set SVG as default namespace for <svg>', () => {57 let template;58 template = () => createElement('svg', null);59 render(template(), container);60 expect(container.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');61 render(template(), container);62 template = () => createElement('svg', null, createElement('path', null));63 render(template(), container);64 expect(container.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');65 });66 it('should unset a namespaced attributes #1', () => {67 const template = val => createElement('svg', null, createElement('image', { 'xlink:href': val }));68 render(template(null), container);69 render(template('test.jpg'), container);70 expect(container.firstChild.firstChild.getAttributeNS('http://www.w3.org/1999/xlink', 'href')).toBe('test.jpg');71 render(template(null), container);72 expect(container.firstChild.firstChild.hasAttributeNS('http://www.w3.org/1999/xlink', 'href')).toBe(false);73 });74 it('should unset a namespaced attributes #2', () => {75 const template = val =>76 createElement('image', {77 'xlink:href': val78 });79 render(template(null), container);80 expect(container.firstChild.hasAttributeNS('http://www.w3.org/1999/xlink', 'href')).toBe(false);81 render(template(null), container);82 expect(container.firstChild.hasAttributeNS('http://www.w3.org/1999/xlink', 'href')).toBe(false);83 });84 it('should unset a namespaced attributes #3', () => {85 const template = val =>86 createElement('svg', {87 xmlns: 'http://www.w3.org/2000/svg',88 'xlink:href': val89 });90 render(template(null), container);91 expect(container.firstChild.hasAttributeNS('http://www.w3.org/1999/xlink', 'href')).toBe(false);92 render(template('test.jpg'), container);93 expect(container.firstChild.getAttributeNS('http://www.w3.org/1999/xlink', 'href')).toBe('test.jpg');94 });95 it('should use the parent namespace by default (static)', () => {96 let template;97 template = () => createElement('svg', null, createElement('circle', null));98 render(template(), container);99 expect(container.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');100 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');101 render(template(), container);102 expect(container.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');103 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');104 template = () => createElement('svg', null, createElement('path', null));105 render(template(), container);106 expect(container.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');107 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');108 template = () => createElement('svg', null);109 render(template(), container);110 expect(container.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');111 });112 it('should handle SVG edge case (static)', () => {113 const template = child => createElement('div', null, createElement('svg', null));114 render(template(), container);115 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');116 render(template(), container);117 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');118 });119 it('should keep parent namespace (dynamic)', () => {120 let child,121 template = _child =>122 createElement(123 'svg',124 {125 xmlns: 'http://www.w3.org/2000/svg'126 },127 _child128 );129 child = () => createElement('circle', null);130 render(template(child()), container);131 expect(container.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');132 render(template(null), container);133 child = () =>134 createElement(135 'circle',136 {137 xmlns: 'http://www.w3.org/2000/svg'138 },139 createElement('circle', {140 xmlns: 'http://www.w3.org/2000/svg'141 })142 );143 render(template(child()), container);144 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');145 expect(container.firstChild.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');146 render(template(null), container);147 child = () =>148 createElement(149 'circle',150 null,151 createElement(152 'circle',153 null,154 createElement('g', {155 xmlns: 'http://www.w3.org/2000/svg'156 })157 )158 );159 render(template(child()), container);160 expect(container.firstChild.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');161 expect(container.firstChild.firstChild.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');162 child = () => createElement('circle', null, createElement('circle', null, createElement('g', null, createElement('g', null))));163 render(template(child()), container);164 expect(container.firstChild.firstChild.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');165 child = () =>166 createElement('circle', null, createElement('circle', null, createElement('g', null, createElement('g', null, createElement('circle', null)))));167 render(template(null), container);168 render(template(child()), container);169 expect(container.firstChild.firstChild.firstChild.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');170 render(template(null), container);171 render(template(child()), container);172 expect(container.firstChild.firstChild.firstChild.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');173 });174 it('should set class attribute', () => {175 const template = val =>176 createElement('image', {177 class: val178 });179 render(template('foo'), container);180 expect(container.firstChild.getAttribute('class')).toBe('foo');181 render(template(null), container);182 render(template('bar'), container);183 expect(container.firstChild.getAttribute('class')).toBe('bar');184 render(template(['bar']), container);185 expect(container.firstChild.getAttribute('class')).toBe('bar');186 render(template(['bar', 'zoo']), container);187 expect(container.firstChild.getAttribute('class')).toBe('bar,zoo');188 // TODO! Fix this189 // render(template([ 'bar', null, 'zoo' ]), container);190 // expect(container.firstChild.getAttribute('class')).toEqual('bar,zoo');191 });192 it('should respect SVG namespace and render SVG attributes', () => {193 const template = (val1, val2) =>194 createElement('svg', {195 xmlns: 'http://www.w3.org/2000/svg',196 version: '1.1',197 baseProfile: 'full',198 width: val1,199 height: val2200 });201 render(template(200, 200), container);202 expect(container.firstChild.tagName.toLowerCase()).toEqual('svg');203 expect(container.firstChild.namespaceURI).toEqual('http://www.w3.org/2000/svg');204 expect(container.firstChild.getAttribute('xmlns')).toEqual('http://www.w3.org/2000/svg');205 expect(container.firstChild.getAttribute('version')).toEqual('1.1');206 expect(container.firstChild.getAttribute('baseProfile')).toEqual('full');207 expect(container.firstChild.getAttribute('width')).toEqual('200');208 expect(container.firstChild.getAttribute('height')).toEqual('200');209 render(template(300, 300), container);210 expect(container.firstChild.tagName.toLowerCase()).toEqual('svg');211 expect(container.firstChild.namespaceURI).toEqual('http://www.w3.org/2000/svg');212 expect(container.firstChild.getAttribute('xmlns')).toEqual('http://www.w3.org/2000/svg');213 expect(container.firstChild.getAttribute('version')).toEqual('1.1');214 expect(container.firstChild.getAttribute('baseProfile')).toEqual('full');215 expect(container.firstChild.getAttribute('width')).toEqual('300');216 expect(container.firstChild.getAttribute('height')).toEqual('300');217 });218 it('should set "viewBox" attribute', () => {219 const template = () =>220 createElement('svg', {221 xmlns: 'http://www.w3.org/2000/svg',222 viewBox: '0 0 50 20'223 });224 render(template(), container);225 expect(container.firstChild.tagName.toLowerCase()).toEqual('svg');226 expect(container.firstChild.namespaceURI).toEqual('http://www.w3.org/2000/svg');227 expect(container.firstChild.getAttribute('xmlns')).toEqual('http://www.w3.org/2000/svg');228 expect(container.firstChild.getAttribute('viewBox')).toEqual('0 0 50 20');229 render(template(), container);230 expect(container.firstChild.tagName.toLowerCase()).toEqual('svg');231 expect(container.firstChild.namespaceURI).toEqual('http://www.w3.org/2000/svg');232 expect(container.firstChild.getAttribute('xmlns')).toEqual('http://www.w3.org/2000/svg');233 expect(container.firstChild.getAttribute('viewBox')).toEqual('0 0 50 20');234 });235 it('should solve SVG edge when wrapped inside a non-namespace element (static)', () => {236 const template = () => createElement('div', null, createElement('svg', null));237 render(template(), container);238 // expect(container.firstChild.firstChild.tagName).toEqual('http://www.w3.org/2000/svg');239 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');240 });241 it('should solve SVG edge case with XMLNS attribute when wrapped inside a non-namespace element (static)', () => {242 const template = () =>243 createElement(244 'div',245 {246 xmlns: 'http://www.w3.org/2000/svg'247 },248 createElement('svg', null)249 );250 render(template(), container);251 // expect(container.firstChild.firstChild.tagName).toEqual('http://www.w3.org/2000/svg');252 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');253 });254 it('should solve SVG edge when wrapped inside a non-namespace element (static)', () => {255 const template = () =>256 createElement(257 'div',258 null,259 createElement('svg', {260 xmlns: 'http://www.w3.org/2000/svg'261 })262 );263 render(template(), container);264 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');265 render(template(), container);266 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');267 });268 it('should be possible to add className to SVG', () => {269 const template = () =>270 createElement('svg', {271 xmlns: 'http://www.w3.org/2000/svg',272 className: 'class1 class2'273 });274 render(template(), container);275 expect(container.firstChild.getAttribute('class')).toBe('class1 class2');276 });277 it('should be possible to remove className from SVG', () => {278 const template = val =>279 createElement('svg', {280 xmlns: 'http://www.w3.org/2000/svg',281 className: val282 });283 render(template('class1 class2'), container);284 expect(container.firstChild.getAttribute('class')).toBe('class1 class2');285 render(template('class1'), container);286 expect(container.firstChild.getAttribute('class')).toBe('class1');287 render(template(), container);288 expect(container.firstChild.getAttribute('class')).toBe(null);289 });290 it('should follow last wins when both class and className are defined', () => {291 const template = () =>292 createElement('svg', {293 xmlns: 'http://www.w3.org/2000/svg',294 class: 'test',295 className: 'class1 class2'296 });297 render(template(), container);298 expect(container.firstChild.getAttribute('class')).toBe('class1 class2');299 });300 it('should respect XHTML namespace inside foreignObject of SVG', () => {301 const template = extraElement =>302 createElement('svg', null, createElement('foreignObject', null, createElement('div', null, extraElement ? createElement('p') : null)));303 render(template(false), container);304 expect(container.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');305 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');306 expect(container.firstChild.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/1999/xhtml');307 render(template(true), container);308 expect(container.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');309 expect(container.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/2000/svg');310 expect(container.firstChild.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/1999/xhtml');311 expect(container.firstChild.firstChild.firstChild.firstChild.namespaceURI).toBe('http://www.w3.org/1999/xhtml');312 });...

Full Screen

Full Screen

bind.spec.js

Source:bind.spec.js Github

copy

Full Screen

1import Vue from 'vue'2describe('Directive v-bind', () => {3 it('normal attr', done => {4 const vm = new Vue({5 template: '<div><span :test="foo">hello</span></div>',6 data: { foo: 'ok' }7 }).$mount()8 expect(vm.$el.firstChild.getAttribute('test')).toBe('ok')9 vm.foo = 'again'10 waitForUpdate(() => {11 expect(vm.$el.firstChild.getAttribute('test')).toBe('again')12 vm.foo = null13 }).then(() => {14 expect(vm.$el.firstChild.hasAttribute('test')).toBe(false)15 vm.foo = false16 }).then(() => {17 expect(vm.$el.firstChild.hasAttribute('test')).toBe(false)18 vm.foo = true19 }).then(() => {20 expect(vm.$el.firstChild.getAttribute('test')).toBe('true')21 vm.foo = 022 }).then(() => {23 expect(vm.$el.firstChild.getAttribute('test')).toBe('0')24 }).then(done)25 })26 it('should set property for input value', done => {27 const vm = new Vue({28 template: `29 <div>30 <input type="text" :value="foo">31 <input type="checkbox" :checked="bar">32 </div>33 `,34 data: {35 foo: 'ok',36 bar: false37 }38 }).$mount()39 expect(vm.$el.firstChild.value).toBe('ok')40 expect(vm.$el.lastChild.checked).toBe(false)41 vm.bar = true42 waitForUpdate(() => {43 expect(vm.$el.lastChild.checked).toBe(true)44 }).then(done)45 })46 it('xlink', done => {47 const vm = new Vue({48 template: '<svg><a :xlink:special="foo"></a></svg>',49 data: {50 foo: 'ok'51 }52 }).$mount()53 const xlinkNS = 'http://www.w3.org/1999/xlink'54 expect(vm.$el.firstChild.getAttributeNS(xlinkNS, 'special')).toBe('ok')55 vm.foo = 'again'56 waitForUpdate(() => {57 expect(vm.$el.firstChild.getAttributeNS(xlinkNS, 'special')).toBe('again')58 vm.foo = null59 }).then(() => {60 expect(vm.$el.firstChild.hasAttributeNS(xlinkNS, 'special')).toBe(false)61 vm.foo = true62 }).then(() => {63 expect(vm.$el.firstChild.getAttributeNS(xlinkNS, 'special')).toBe('true')64 }).then(done)65 })66 it('enumerated attr', done => {67 const vm = new Vue({68 template: '<div><span :draggable="foo">hello</span></div>',69 data: { foo: true }70 }).$mount()71 expect(vm.$el.firstChild.getAttribute('draggable')).toBe('true')72 vm.foo = 'again'73 waitForUpdate(() => {74 expect(vm.$el.firstChild.getAttribute('draggable')).toBe('true')75 vm.foo = null76 }).then(() => {77 expect(vm.$el.firstChild.getAttribute('draggable')).toBe('false')78 vm.foo = ''79 }).then(() => {80 expect(vm.$el.firstChild.getAttribute('draggable')).toBe('true')81 vm.foo = false82 }).then(() => {83 expect(vm.$el.firstChild.getAttribute('draggable')).toBe('false')84 vm.foo = 'false'85 }).then(() => {86 expect(vm.$el.firstChild.getAttribute('draggable')).toBe('false')87 }).then(done)88 })89 it('boolean attr', done => {90 const vm = new Vue({91 template: '<div><span :disabled="foo">hello</span></div>',92 data: { foo: true }93 }).$mount()94 expect(vm.$el.firstChild.getAttribute('disabled')).toBe('disabled')95 vm.foo = 'again'96 waitForUpdate(() => {97 expect(vm.$el.firstChild.getAttribute('disabled')).toBe('disabled')98 vm.foo = null99 }).then(() => {100 expect(vm.$el.firstChild.hasAttribute('disabled')).toBe(false)101 vm.foo = ''102 }).then(() => {103 expect(vm.$el.firstChild.hasAttribute('disabled')).toBe(true)104 }).then(done)105 })106 it('.prop modifier', () => {107 const vm = new Vue({108 template: '<div><span v-bind:text-content.prop="foo"></span><span :inner-html.prop="bar"></span></div>',109 data: {110 foo: 'hello',111 bar: '<span>qux</span>'112 }113 }).$mount()114 expect(vm.$el.children[0].textContent).toBe('hello')115 expect(vm.$el.children[1].innerHTML).toBe('<span>qux</span>')116 })117 it('.prop modifier with normal attribute binding', () => {118 const vm = new Vue({119 template: '<input :some.prop="some" :id="id">',120 data: {121 some: 'hello',122 id: false123 }124 }).$mount()125 expect(vm.$el.some).toBe('hello')126 expect(vm.$el.getAttribute('id')).toBe(null)127 })128 it('.camel modifier', () => {129 const vm = new Vue({130 template: '<svg :view-box.camel="viewBox"></svg>',131 data: {132 viewBox: '0 0 1 1'133 }134 }).$mount()135 expect(vm.$el.getAttribute('viewBox')).toBe('0 0 1 1')136 })137 it('.sync modifier', done => {138 const vm = new Vue({139 template: `<test :foo-bar.sync="bar"/>`,140 data: {141 bar: 1142 },143 components: {144 test: {145 props: ['fooBar'],146 template: `<div @click="$emit('update:fooBar', 2)">{{ fooBar }}</div>`147 }148 }149 }).$mount()150 expect(vm.$el.textContent).toBe('1')151 triggerEvent(vm.$el, 'click')152 waitForUpdate(() => {153 expect(vm.$el.textContent).toBe('2')154 }).then(done)155 })156 it('bind object', done => {157 const vm = new Vue({158 template: '<input v-bind="test">',159 data: {160 test: {161 id: 'test',162 class: 'ok',163 value: 'hello'164 }165 }166 }).$mount()167 expect(vm.$el.getAttribute('id')).toBe('test')168 expect(vm.$el.getAttribute('class')).toBe('ok')169 expect(vm.$el.value).toBe('hello')170 vm.test.id = 'hi'171 vm.test.value = 'bye'172 waitForUpdate(() => {173 expect(vm.$el.getAttribute('id')).toBe('hi')174 expect(vm.$el.getAttribute('class')).toBe('ok')175 expect(vm.$el.value).toBe('bye')176 }).then(done)177 })178 it('bind object with overwrite', done => {179 const vm = new Vue({180 template: '<input v-bind="test" id="foo" :class="test.value">',181 data: {182 test: {183 id: 'test',184 class: 'ok',185 value: 'hello'186 }187 }188 }).$mount()189 expect(vm.$el.getAttribute('id')).toBe('foo')190 expect(vm.$el.getAttribute('class')).toBe('hello')191 expect(vm.$el.value).toBe('hello')192 vm.test.id = 'hi'193 vm.test.value = 'bye'194 waitForUpdate(() => {195 expect(vm.$el.getAttribute('id')).toBe('foo')196 expect(vm.$el.getAttribute('class')).toBe('bye')197 expect(vm.$el.value).toBe('bye')198 }).then(done)199 })200 it('bind object with class/style', done => {201 const vm = new Vue({202 template: '<input class="a" style="color:red" v-bind="test">',203 data: {204 test: {205 id: 'test',206 class: ['b', 'c'],207 style: { fontSize: '12px' }208 }209 }210 }).$mount()211 expect(vm.$el.id).toBe('test')212 expect(vm.$el.className).toBe('a b c')213 expect(vm.$el.style.color).toBe('red')214 expect(vm.$el.style.fontSize).toBe('12px')215 vm.test.id = 'hi'216 vm.test.class = ['d']217 vm.test.style = { fontSize: '14px' }218 waitForUpdate(() => {219 expect(vm.$el.id).toBe('hi')220 expect(vm.$el.className).toBe('a d')221 expect(vm.$el.style.color).toBe('red')222 expect(vm.$el.style.fontSize).toBe('14px')223 }).then(done)224 })225 it('bind object as prop', done => {226 const vm = new Vue({227 template: '<input v-bind.prop="test">',228 data: {229 test: {230 id: 'test',231 className: 'ok',232 value: 'hello'233 }234 }235 }).$mount()236 expect(vm.$el.id).toBe('test')237 expect(vm.$el.className).toBe('ok')238 expect(vm.$el.value).toBe('hello')239 vm.test.id = 'hi'240 vm.test.className = 'okay'241 vm.test.value = 'bye'242 waitForUpdate(() => {243 expect(vm.$el.id).toBe('hi')244 expect(vm.$el.className).toBe('okay')245 expect(vm.$el.value).toBe('bye')246 }).then(done)247 })248 it('bind array', done => {249 const vm = new Vue({250 template: '<input v-bind="test">',251 data: {252 test: [253 { id: 'test', class: 'ok' },254 { value: 'hello' }255 ]256 }257 }).$mount()258 expect(vm.$el.getAttribute('id')).toBe('test')259 expect(vm.$el.getAttribute('class')).toBe('ok')260 expect(vm.$el.value).toBe('hello')261 vm.test[0].id = 'hi'262 vm.test[1].value = 'bye'263 waitForUpdate(() => {264 expect(vm.$el.getAttribute('id')).toBe('hi')265 expect(vm.$el.getAttribute('class')).toBe('ok')266 expect(vm.$el.value).toBe('bye')267 }).then(done)268 })269 it('warn expect object', () => {270 new Vue({271 template: '<input v-bind="test">',272 data: {273 test: 1274 }275 }).$mount()276 expect('v-bind without argument expects an Object or Array value').toHaveBeenWarned()277 })278 it('set value for option element', () => {279 const vm = new Vue({280 template: '<select><option :value="val">val</option></select>',281 data: {282 val: 'val'283 }284 }).$mount()285 // check value attribute286 expect(vm.$el.options[0].getAttribute('value')).toBe('val')287 })288 // a vdom patch edge case where the user has several un-keyed elements of the289 // same tag next to each other, and toggling them.290 it('properly update for toggling un-keyed children', done => {291 const vm = new Vue({292 template: `293 <div>294 <div v-if="ok" id="a" data-test="1"></div>295 <div v-if="!ok" id="b"></div>296 </div>297 `,298 data: {299 ok: true300 }301 }).$mount()302 expect(vm.$el.children[0].id).toBe('a')303 expect(vm.$el.children[0].getAttribute('data-test')).toBe('1')304 vm.ok = false305 waitForUpdate(() => {306 expect(vm.$el.children[0].id).toBe('b')307 expect(vm.$el.children[0].getAttribute('data-test')).toBe(null)308 }).then(done)309 })...

Full Screen

Full Screen

DOMPropertyOperations-test.js

Source:DOMPropertyOperations-test.js Github

copy

Full Screen

1/**2 * Copyright (c) Facebook, Inc. and its affiliates.3 *4 * This source code is licensed under the MIT license found in the5 * LICENSE file in the root directory of this source tree.6 *7 * @emails react-core8 */9'use strict';10// Set by `yarn test-fire`.11const {disableInputAttributeSyncing} = require('shared/ReactFeatureFlags');12describe('DOMPropertyOperations', () => {13 let React;14 let ReactDOM;15 beforeEach(() => {16 jest.resetModules();17 React = require('react');18 ReactDOM = require('react-dom');19 });20 describe('setValueForProperty', () => {21 it('should set values as properties by default', () => {22 const container = document.createElement('div');23 ReactDOM.render(<div title="Tip!" />, container);24 expect(container.firstChild.title).toBe('Tip!');25 });26 it('should set values as attributes if necessary', () => {27 const container = document.createElement('div');28 ReactDOM.render(<div role="#" />, container);29 expect(container.firstChild.getAttribute('role')).toBe('#');30 expect(container.firstChild.role).toBeUndefined();31 });32 it('should set values as namespace attributes if necessary', () => {33 const container = document.createElementNS(34 'http://www.w3.org/2000/svg',35 'svg',36 );37 ReactDOM.render(<image xlinkHref="about:blank" />, container);38 expect(39 container.firstChild.getAttributeNS(40 'http://www.w3.org/1999/xlink',41 'href',42 ),43 ).toBe('about:blank');44 });45 it('should set values as boolean properties', () => {46 const container = document.createElement('div');47 ReactDOM.render(<div disabled="disabled" />, container);48 expect(container.firstChild.getAttribute('disabled')).toBe('');49 ReactDOM.render(<div disabled={true} />, container);50 expect(container.firstChild.getAttribute('disabled')).toBe('');51 ReactDOM.render(<div disabled={false} />, container);52 expect(container.firstChild.getAttribute('disabled')).toBe(null);53 ReactDOM.render(<div disabled={true} />, container);54 ReactDOM.render(<div disabled={null} />, container);55 expect(container.firstChild.getAttribute('disabled')).toBe(null);56 ReactDOM.render(<div disabled={true} />, container);57 ReactDOM.render(<div disabled={undefined} />, container);58 expect(container.firstChild.getAttribute('disabled')).toBe(null);59 });60 it('should convert attribute values to string first', () => {61 // Browsers default to this behavior, but some test environments do not.62 // This ensures that we have consistent behavior.63 const obj = {64 toString: function() {65 return 'css-class';66 },67 };68 const container = document.createElement('div');69 ReactDOM.render(<div className={obj} />, container);70 expect(container.firstChild.getAttribute('class')).toBe('css-class');71 });72 it('should not remove empty attributes for special input properties', () => {73 const container = document.createElement('div');74 ReactDOM.render(<input value="" onChange={() => {}} />, container);75 if (disableInputAttributeSyncing) {76 expect(container.firstChild.hasAttribute('value')).toBe(false);77 } else {78 expect(container.firstChild.getAttribute('value')).toBe('');79 }80 expect(container.firstChild.value).toBe('');81 });82 it('should not remove empty attributes for special option properties', () => {83 const container = document.createElement('div');84 ReactDOM.render(85 <select>86 <option value="">empty</option>87 <option>filled</option>88 </select>,89 container,90 );91 // Regression test for https://github.com/facebook/react/issues/621992 expect(container.firstChild.firstChild.value).toBe('');93 expect(container.firstChild.lastChild.value).toBe('filled');94 });95 it('should remove for falsey boolean properties', () => {96 const container = document.createElement('div');97 ReactDOM.render(<div allowFullScreen={false} />, container);98 expect(container.firstChild.hasAttribute('allowFullScreen')).toBe(false);99 });100 it('should remove when setting custom attr to null', () => {101 const container = document.createElement('div');102 ReactDOM.render(<div data-foo="bar" />, container);103 expect(container.firstChild.hasAttribute('data-foo')).toBe(true);104 ReactDOM.render(<div data-foo={null} />, container);105 expect(container.firstChild.hasAttribute('data-foo')).toBe(false);106 });107 it('should set className to empty string instead of null', () => {108 const container = document.createElement('div');109 ReactDOM.render(<div className="selected" />, container);110 expect(container.firstChild.className).toBe('selected');111 ReactDOM.render(<div className={null} />, container);112 // className should be '', not 'null' or null (which becomes 'null' in113 // some browsers)114 expect(container.firstChild.className).toBe('');115 expect(container.firstChild.getAttribute('class')).toBe(null);116 });117 it('should remove property properly for boolean properties', () => {118 const container = document.createElement('div');119 ReactDOM.render(<div hidden={true} />, container);120 expect(container.firstChild.hasAttribute('hidden')).toBe(true);121 ReactDOM.render(<div hidden={false} />, container);122 expect(container.firstChild.hasAttribute('hidden')).toBe(false);123 });124 it('should always assign the value attribute for non-inputs', function() {125 const container = document.createElement('div');126 ReactDOM.render(<progress />, container);127 spyOnDevAndProd(container.firstChild, 'setAttribute');128 ReactDOM.render(<progress value={30} />, container);129 ReactDOM.render(<progress value="30" />, container);130 expect(container.firstChild.setAttribute).toHaveBeenCalledTimes(2);131 });132 it('should return the progress to intermediate state on null value', () => {133 const container = document.createElement('div');134 ReactDOM.render(<progress value={30} />, container);135 ReactDOM.render(<progress value={null} />, container);136 // Ensure we move progress back to an indeterminate state.137 // Regression test for https://github.com/facebook/react/issues/6119138 expect(container.firstChild.hasAttribute('value')).toBe(false);139 });140 });141 describe('deleteValueForProperty', () => {142 it('should remove attributes for normal properties', () => {143 const container = document.createElement('div');144 ReactDOM.render(<div title="foo" />, container);145 expect(container.firstChild.getAttribute('title')).toBe('foo');146 ReactDOM.render(<div />, container);147 expect(container.firstChild.getAttribute('title')).toBe(null);148 });149 it('should not remove attributes for special properties', () => {150 const container = document.createElement('div');151 ReactDOM.render(152 <input type="text" value="foo" onChange={function() {}} />,153 container,154 );155 if (disableInputAttributeSyncing) {156 expect(container.firstChild.hasAttribute('value')).toBe(false);157 } else {158 expect(container.firstChild.getAttribute('value')).toBe('foo');159 }160 expect(container.firstChild.value).toBe('foo');161 expect(() =>162 ReactDOM.render(163 <input type="text" onChange={function() {}} />,164 container,165 ),166 ).toWarnDev(167 'A component is changing a controlled input of type text to be uncontrolled',168 );169 if (disableInputAttributeSyncing) {170 expect(container.firstChild.hasAttribute('value')).toBe(false);171 } else {172 expect(container.firstChild.getAttribute('value')).toBe('foo');173 }174 expect(container.firstChild.value).toBe('foo');175 });176 it('should not remove attributes for custom component tag', () => {177 const container = document.createElement('div');178 ReactDOM.render(<my-icon size="5px" />, container);179 expect(container.firstChild.getAttribute('size')).toBe('5px');180 });181 });...

Full Screen

Full Screen

notification_test.js

Source:notification_test.js Github

copy

Full Screen

...17 assert.equal(this.view.el.getAttribute('role'), 'presentation');18 this.view.display({ text: 'l10nId' });19 var child = this.view.el.children[0];20 assert.ok(child);21 assert.equal(child.getAttribute('role'), 'status');22 assert.equal(child.getAttribute('aria-live'), 'assertive');23 });24 test('Should add `text` as textContent', function() {25 this.view.display({ text: 'l10nId' });26 var child = this.view.el.children[0];27 assert.equal(child.firstChild.getAttribute('data-l10n-id'), 'l10nId');28 assert.equal(child.getAttribute('role'), 'status');29 assert.equal(child.getAttribute('aria-live'), 'assertive');30 });31 test('Should assign className to the item element', function() {32 this.view.display({ text: 'l10nId', className: 'bar' });33 var child = this.view.el.children[0];34 assert.isTrue(child.classList.contains('bar'));35 assert.equal(child.getAttribute('role'), 'status');36 assert.equal(child.getAttribute('aria-live'), 'assertive');37 });38 test('Should remove the last non-persistent item that is in the way', function() {39 this.view.display({ text: 'l10nId' });40 var first = this.view.el.children[0];41 assert.ok(first);42 assert.equal(first.firstChild.getAttribute('data-l10n-id'), 'l10nId');43 this.view.display({ text: 'l10nId2' });44 var second = this.view.el.children[0];45 assert.ok(second);46 assert.equal(first.parentNode, null, 'not in dom');47 assert.equal(second.firstChild.getAttribute('data-l10n-id'),48 'l10nId2');49 });50 test('Should auto clear notification after 3s', function() {...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...122/**123 * The following part can be removed when rough.js adds support for rendering svgs.124 */125function getFillStroke(child) {126 var fill = nullIfNone(child.getAttribute('fill'));127 var stroke = nullIfNone(child.getAttribute('stroke'));128 var isBaseRectangle = child.nodeName === 'polygon' && child.parentNode.id === 'graph0';129 return {130 fill: isBaseRectangle ? 'white' : fill,131 fillStyle: isBaseRectangle ? 'solid' : 'hachure',132 stroke: stroke133 };134}135function splitToArgs(array, delimiter) {136 return array.split(delimiter || ',').map(v => +v);137}138// node traversal function139function traverseSvgToRough(child) {140 if (child.nodeName === 'path') {141 var d = child.getAttribute('d');142 var opts = getFillStroke(child);143 rc.path(d, opts);144 return;145 }146 if (child.nodeName === 'ellipse') {147 var cx = +child.getAttribute('cx');148 var cy = +child.getAttribute('cy');149 var rx = +child.getAttribute('rx');150 var ry = +child.getAttribute('ry');151 var opts = getFillStroke(child);152 rc.ellipse(cx, cy, rx * 1.5, ry * 1.5);153 return;154 }155 if (child.nodeName === 'text') {156 var fontFamily = child.getAttribute('font-family')157 var fontSize = +child.getAttribute('font-size')158 var anchor = child.getAttribute('text-anchor')159 if (anchor === 'middle') {160 ctx.textAlign = 'center';161 }162 if (fontFamily) {163 ctx.fontFamily = fontFamily;164 }165 if (fontSize) {166 ctx.fontSize = fontSize;167 }168 ctx.fillText(child.textContent, child.getAttribute('x'), child.getAttribute('y'));169 return;170 }171 if (child.nodeName === 'polygon') {172 var pts = child.getAttribute('points')173 var opts = getFillStroke(child);174 rc.path(`M${pts}Z`, opts);175 return;176 }177 if (child.nodeName === 'g') {178 var transform = child.getAttribute('transform');179 ctx.save();180 if (transform) {181 var scale = /scale\(([^)]*)\)/.exec(transform);182 if (scale) {183 var args = scale[1].split(' ').map(parseFloat);184 ctx.scale(...args);185 }186 var rotate = /rotate\(([^)]*)\)/.exec(transform);187 if (rotate) {188 var args = rotate[1].split(' ').map(parseFloat);189 ctx.rotate(...args);190 }191 var translate = /translate\(([^)]*)\)/.exec(transform);192 if (translate) {...

Full Screen

Full Screen

props.spec.js

Source:props.spec.js Github

copy

Full Screen

1// eslint-disable-next-line @typescript-eslint/no-unused-vars2import * as React from 'react'3let document4let render5let runtime6describe('Context', () => {7 beforeAll(() => {8 process.env.FRAMEWORK = 'react'9 runtime = require('@tarojs/runtime')10 render = require('../dist/index').render11 document = runtime.document12 })13 afterAll(() => {14 process.env.FRAMEWORK = undefined15 })16 describe('setValueOnElement', () => {17 it('should set values as properties by default', () => {18 const container = document.createElement('div')19 render(<div title="Tip!" />, container)20 expect(container.firstChild.getAttribute('title')).toBe('Tip!')21 })22 it('should set values as attributes if necessary', () => {23 const container = document.createElement('div')24 render(<div role="#" />, container)25 expect(container.firstChild.getAttribute('role')).toBe('#')26 expect(container.firstChild.role).toBeUndefined()27 })28 it('should set values as attributes for specific props', () => {29 const container = document.createElement('div')30 render(<view type="button" id="test" />, container)31 expect(container.firstChild.getAttribute('type')).toBe('button')32 expect(container.firstChild.id).toBe('test')33 })34 it('className should works as class', () => {35 const container = document.createElement('div')36 render(<input type="button" className='test' />, container)37 expect(container.firstChild.getAttribute('class')).toBe('test')38 })39 it('string style', () => {40 const container = document.createElement('div')41 render(<input type="button" style='color: red' />, container)42 expect(container.firstChild.getAttribute('style')).toBe('color: red;')43 })44 it('object style', () => {45 const container = document.createElement('div')46 render(<input type="button" style={{ color: 'red' }} />, container)47 expect(container.firstChild.getAttribute('style')).toBe('color: red;')48 })49 it('set style as number', () => {50 const container = document.createElement('div')51 render(<input type="button" style={{ fontSize: 14 }} />, container)52 expect(container.firstChild.getAttribute('style')).toBe('font-size: 14px;')53 })54 it('onClick should work like onTap', () => {55 const container = document.createElement('div')56 const spy = jest.fn()57 render(<div type="button" onClick={spy} />, container)58 expect('tap' in container.firstChild.__handlers).toBe(true)59 })60 it('can dispatch event', () => {61 const createEvent = runtime.createEvent62 const container = document.createElement('div')63 const spy = jest.fn()64 render(<div type="button" onClick={spy} id='fork' />, container)65 const event = createEvent({ type: 'tap', currentTarget: { id: container.firstChild.uid }, target: { id: container.firstChild.uid } })66 container.firstChild.dispatchEvent(event)67 expect(spy).toBeCalled()68 })69 it('should patch properies properly', () => {70 const container = document.createElement('div')71 render(<div id='1' />, container)72 render(<div id='2' />, container)73 expect(container.firstChild.id).toBe('2')74 })75 it('should patch properies properly 2', () => {76 const container = document.createElement('div')77 render(<div id='1' a='a' />, container)78 render(<div id='2' b='b' />, container)79 expect(container.firstChild.id).toBe('2')80 expect(container.firstChild.getAttribute('a')).toBe('')81 expect(container.firstChild.getAttribute('b')).toBe('b')82 })83 it('should ignore ref', () => {84 const container = document.createElement('div')85 render(<div ref={React.createRef} />, container)86 expect(container.firstChild.getAttribute('ref')).toBe('')87 })88 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var childAttribute = child.getAttribute("name");2var childText = child.getText();3var childAttribute = child.getAttribute("name");4var childText = child.getText();5var childAttribute = child.getAttribute("name");6var childText = child.getText();7var childAttribute = child.getAttribute("name");8var childText = child.getText();9var childAttribute = child.getAttribute("name");10var childText = child.getText();11var childAttribute = child.getAttribute("name");12var childText = child.getText();

Full Screen

Using AI Code Generation

copy

Full Screen

1var child = driver.findElementByAccessibilityId('AccessibilityId');2var attribute = child.getAttribute('name');3var child = driver.findElementByAccessibilityId('AccessibilityId');4var attribute = child.getAttribute('name');5var child = driver.findElementByAccessibilityId('AccessibilityId');6var attribute = child.getAttribute('name');7var child = driver.findElementByAccessibilityId('AccessibilityId');8var attribute = child.getAttribute('name');9var child = driver.findElementByAccessibilityId('AccessibilityId');10var attribute = child.getAttribute('name');11var child = driver.findElementByAccessibilityId('AccessibilityId');12var attribute = child.getAttribute('name');13var child = driver.findElementByAccessibilityId('AccessibilityId');14var attribute = child.getAttribute('name');15var child = driver.findElementByAccessibilityId('AccessibilityId');16var attribute = child.getAttribute('name');17var child = driver.findElementByAccessibilityId('AccessibilityId');18var attribute = child.getAttribute('name');19var child = driver.findElementByAccessibilityId('AccessibilityId');20var attribute = child.getAttribute('name');21var child = driver.findElementByAccessibilityId('AccessibilityId');22var attribute = child.getAttribute('name');23var child = driver.findElementByAccessibilityId('AccessibilityId');24var attribute = child.getAttribute('name');25var child = driver.findElementByAccessibilityId('AccessibilityId');26var attribute = child.getAttribute('name');27var child = driver.findElementByAccessibilityId('AccessibilityId');28var attribute = child.getAttribute('name');

Full Screen

Using AI Code Generation

copy

Full Screen

1child.getAttribute('name').then(function (text) {2 console.log('Child Attribute: ' + text);3});4child.getAttribute('name').then(function (text) {5 console.log('Child Attribute: ' + text);6});7child.getAttribute('name').then(function (text) {8 console.log('Child Attribute: ' + text);9});10child.getAttribute('name').then(function (text) {11 console.log('Child Attribute: ' + text);12});13child.getAttribute('name').then(function (text) {14 console.log('Child Attribute: ' + text);15});16child.getAttribute('name').then(function (text) {17 console.log('Child Attribute: ' + text);18});19child.getAttribute('name').then(function (text) {20 console.log('Child Attribute: ' + text);21});22child.getAttribute('name').then(function (text) {23 console.log('Child Attribute: ' + text);24});25child.getAttribute('name').then(function (text) {26 console.log('Child Attribute: ' + text);27});28child.getAttribute('name').then(function (text) {29 console.log('Child Attribute: ' + text);30});31child.getAttribute('name').then(function (text) {32 console.log('Child Attribute: ' + text);33});34child.getAttribute('name').then(function (text) {35 console.log('Child Attribute: ' + text);36});37child.getAttribute('name').then(function (text) {38 console.log('Child Attribute: ' + text);39});40child.getAttribute('name').then(function (text) {41 console.log('Child Attribute: '

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var caps = {4};5var driver = wd.promiseChainRemote('localhost', 4723);6driver.init(caps).then(function() {7 return driver.elementByAccessibilityId("MyElement")8}).then(function(element) {9 return element.getAttribute("value")10}).then(function(value) {11 assert.equal(value, "MyValue")12}).fin(function() { return driver.quit(); })13 .done();14var wd = require('wd');15var assert = require('assert');16var caps = {17};18var driver = wd.promiseChainRemote('localhost', 4723);19driver.init(caps).then(function() {20 return driver.elementByAccessibilityId("MyElement")21}).then(function(element) {22 return element.getAttribute("value")23}).then(function(value) {24 assert.equal(value, "MyValue")25}).fin(function() { return driver.quit(); })26 .done();27var wd = require('wd');28var assert = require('assert');29var caps = {30};31var driver = wd.promiseChainRemote('localhost', 4723);32driver.init(caps).then(function() {33 return driver.elementByAccessibilityId("MyElement")

Full Screen

Using AI Code Generation

copy

Full Screen

1var childAttribute = child.getAttribute("name");2console.log(childAttribute);3var childAttribute = child.getAttribute("name");4console.log(childAttribute);5var childAttribute = child.getAttribute("name");6console.log(childAttribute);7var childAttribute = child.getAttribute("name");8console.log(childAttribute);9var childAttribute = child.getAttribute("name");10console.log(childAttribute);11var childAttribute = child.getAttribute("name");12console.log(childAttribute);13var child = driver.findElement(By.xpath

Full Screen

Using AI Code Generation

copy

Full Screen

1var childType = child.getAttribute("type");2var childType = child.getAttribute("type");3var childType = child.getAttribute("type");4var childType = child.getAttribute("type");5var childType = child.getAttribute("type");6var childType = child.getAttribute("type");7var childType = child.getAttribute("type");

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful