element.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: treeview */
  6. 'use strict';
  7. import utils from '/ckeditor5/utils/utils.js';
  8. import Node from '/ckeditor5/core/treeview/node.js';
  9. import ViewElement from '/ckeditor5/core/treeview/element.js';
  10. describe( 'Element', () => {
  11. describe( 'constructor', () => {
  12. it( 'should create element without attributes', () => {
  13. const el = new ViewElement( 'p' );
  14. expect( el ).to.be.an.instanceof( Node );
  15. expect( el ).to.have.property( 'name' ).that.equals( 'p' );
  16. expect( el ).to.have.property( 'parent' ).that.is.null;
  17. expect( utils.count( el.getAttributeKeys() ) ).to.equal( 0 );
  18. } );
  19. it( 'should create element with attributes as plain object', () => {
  20. const el = new ViewElement( 'p', { foo: 'bar' } );
  21. expect( el ).to.have.property( 'name' ).that.equals( 'p' );
  22. expect( utils.count( el.getAttributeKeys() ) ).to.equal( 1 );
  23. expect( el.getAttribute( 'foo' ) ).to.equal( 'bar' );
  24. } );
  25. it( 'should create element with attributes as map', () => {
  26. const attrs = new Map();
  27. attrs.set( 'foo', 'bar' );
  28. const el = new ViewElement( 'p', attrs );
  29. expect( el ).to.have.property( 'name' ).that.equals( 'p' );
  30. expect( utils.count( el.getAttributeKeys() ) ).to.equal( 1 );
  31. expect( el.getAttribute( 'foo' ) ).to.equal( 'bar' );
  32. } );
  33. it( 'should create element with children', () => {
  34. const child = new ViewElement( 'p', { foo: 'bar' } );
  35. const parent = new ViewElement( 'div', [], [ child ] );
  36. expect( parent ).to.have.property( 'name' ).that.equals( 'div' );
  37. expect( parent.getChildCount() ).to.equal( 1 );
  38. expect( parent.getChild( 0 ) ).to.have.property( 'name' ).that.equals( 'p' );
  39. } );
  40. it( 'should move class attribute to class set ', () => {
  41. const el = new ViewElement( 'p', { id: 'test', class: 'one two three' } );
  42. expect( el._attrs.has( 'class' ) ).to.be.false;
  43. expect( el._attrs.has( 'id' ) ).to.be.true;
  44. expect( el._classes.has( 'one' ) ).to.be.true;
  45. expect( el._classes.has( 'two' ) ).to.be.true;
  46. expect( el._classes.has( 'three' ) ).to.be.true;
  47. } );
  48. it( 'should move style attribute to style map', () => {
  49. const el = new ViewElement( 'p', { id: 'test', style: 'one: style1; two:style2 ; three : url(http://ckeditor.com)' } );
  50. expect( el._attrs.has( 'style' ) ).to.be.false;
  51. expect( el._attrs.has( 'id' ) ).to.be.true;
  52. expect( el._styles.has( 'one' ) ).to.be.true;
  53. expect( el._styles.get( 'one' ) ).to.equal( 'style1' );
  54. expect( el._styles.has( 'two' ) ).to.be.true;
  55. expect( el._styles.get( 'two' ) ).to.equal( 'style2' );
  56. expect( el._styles.has( 'three' ) ).to.be.true;
  57. expect( el._styles.get( 'three' ) ).to.equal( 'url(http://ckeditor.com)' );
  58. } );
  59. } );
  60. describe( 'clone', () => {
  61. it( 'should clone element', () => {
  62. const el = new ViewElement( 'p', { attr1: 'foo', attr2: 'bar' } );
  63. const clone = el.clone();
  64. expect( clone ).to.not.equal( el );
  65. expect( clone.name ).to.equal( el.name );
  66. expect( clone.getAttribute( 'attr1' ) ).to.equal( 'foo' );
  67. expect( clone.getAttribute( 'attr2' ) ).to.equal( 'bar' );
  68. } );
  69. it( 'should deeply clone element', () => {
  70. const el = new ViewElement( 'p', { attr1: 'foo', attr2: 'bar' }, [
  71. new ViewElement( 'b', { attr: 'baz' } ),
  72. new ViewElement( 'span', { attr: 'qux' } )
  73. ] );
  74. const count = el.getChildCount();
  75. const clone = el.clone( true );
  76. expect( clone ).to.not.equal( el );
  77. expect( clone.name ).to.equal( el.name );
  78. expect( clone.getAttribute( 'attr1' ) ).to.equal( 'foo' );
  79. expect( clone.getAttribute( 'attr2' ) ).to.equal( 'bar' );
  80. expect( clone.getChildCount() ).to.equal( count );
  81. for ( let i = 0; i < count; i++ ) {
  82. const child = el.getChild( i );
  83. const clonedChild = clone.getChild( i );
  84. expect( clonedChild ).to.not.equal( child );
  85. expect( clonedChild.name ).to.equal( child.name );
  86. expect( clonedChild.getAttribute( 'attr' ) ).to.equal( child.getAttribute( 'attr' ) );
  87. }
  88. } );
  89. it( 'shouldn\'t clone any children when deep copy is not performed', () => {
  90. const el = new ViewElement( 'p', { attr1: 'foo', attr2: 'bar' }, [
  91. new ViewElement( 'b', { attr: 'baz' } ),
  92. new ViewElement( 'span', { attr: 'qux' } )
  93. ] );
  94. const clone = el.clone( false );
  95. expect( clone ).to.not.equal( el );
  96. expect( clone.name ).to.equal( el.name );
  97. expect( clone.getAttribute( 'attr1' ) ).to.equal( 'foo' );
  98. expect( clone.getAttribute( 'attr2' ) ).to.equal( 'bar' );
  99. expect( clone.getChildCount() ).to.equal( 0 );
  100. } );
  101. it( 'should clone class attribute', () => {
  102. const el = new ViewElement( 'p', { foo: 'bar' } );
  103. el.addClass( 'baz', 'qux' );
  104. const clone = el.clone( false );
  105. expect( clone ).to.not.equal( el );
  106. expect( clone.name ).to.equal( el.name );
  107. expect( clone.getAttribute( 'foo' ) ).to.equal( 'bar' );
  108. expect( clone.getAttribute( 'class' ) ).to.equal( 'baz qux' );
  109. } );
  110. it( 'should clone style attribute', () => {
  111. const el = new ViewElement( 'p', { style: 'color: red; font-size: 12px;' } );
  112. const clone = el.clone( false );
  113. expect( clone ).to.not.equal( el );
  114. expect( clone.name ).to.equal( el.name );
  115. expect( clone._styles.has( 'color' ) ).to.be.true;
  116. expect( clone._styles.get( 'color' ) ).to.equal( 'red' );
  117. expect( clone._styles.has( 'font-size' ) ).to.be.true;
  118. expect( clone._styles.get( 'font-size' ) ).to.equal( '12px' );
  119. } );
  120. } );
  121. describe( 'isSimilar', () => {
  122. const el = new ViewElement( 'p', { foo: 'bar' } );
  123. it( 'should return false when comparing to non-element', () => {
  124. expect( el.isSimilar( null ) ).to.be.false;
  125. expect( el.isSimilar( {} ) ).to.be.false;
  126. } );
  127. it( 'should return true when the same node is provided', () => {
  128. expect( el.isSimilar( el ) ).to.be.true;
  129. } );
  130. it( 'should return true for element with same attributes and name', () => {
  131. const other = new ViewElement( 'p', { foo: 'bar' } );
  132. expect( el.isSimilar( other ) ).to.be.true;
  133. } );
  134. it( 'sould return false when name is not the same', () => {
  135. const other = el.clone();
  136. other.name = 'div';
  137. expect( el.isSimilar( other ) ).to.be.false;
  138. } );
  139. it( 'should return false when attributes are not the same', () => {
  140. const other1 = el.clone();
  141. const other2 = el.clone();
  142. const other3 = el.clone();
  143. other1.setAttribute( 'baz', 'qux' );
  144. other2.setAttribute( 'foo', 'not-bar' );
  145. other3.removeAttribute( 'foo' );
  146. expect( el.isSimilar( other1 ) ).to.be.false;
  147. expect( el.isSimilar( other2 ) ).to.be.false;
  148. expect( el.isSimilar( other3 ) ).to.be.false;
  149. } );
  150. it( 'should compare class attribute', () => {
  151. const el1 = new ViewElement( 'p' );
  152. const el2 = new ViewElement( 'p' );
  153. const el3 = new ViewElement( 'p' );
  154. const el4 = new ViewElement( 'p' );
  155. el1.addClass( 'foo', 'bar' );
  156. el2.addClass( 'bar', 'foo' );
  157. el3.addClass( 'baz' );
  158. el4.addClass( 'baz', 'bar' );
  159. expect( el1.isSimilar( el2 ) ).to.be.true;
  160. expect( el1.isSimilar( el3 ) ).to.be.false;
  161. expect( el1.isSimilar( el4 ) ).to.be.false;
  162. } );
  163. } );
  164. describe( 'children manipulation methods', () => {
  165. let parent, el1, el2, el3, el4;
  166. beforeEach( () => {
  167. parent = new ViewElement( 'p' );
  168. el1 = new ViewElement( 'el1' );
  169. el2 = new ViewElement( 'el2' );
  170. el3 = new ViewElement( 'el3' );
  171. el4 = new ViewElement( 'el4' );
  172. } );
  173. describe( 'insertion', () => {
  174. it( 'should insert children', () => {
  175. const count1 = parent.insertChildren( 0, [ el1, el3 ] );
  176. const count2 = parent.insertChildren( 1, el2 );
  177. expect( parent.getChildCount() ).to.equal( 3 );
  178. expect( parent.getChild( 0 ) ).to.have.property( 'name' ).that.equals( 'el1' );
  179. expect( parent.getChild( 1 ) ).to.have.property( 'name' ).that.equals( 'el2' );
  180. expect( parent.getChild( 2 ) ).to.have.property( 'name' ).that.equals( 'el3' );
  181. expect( count1 ).to.equal( 2 );
  182. expect( count2 ).to.equal( 1 );
  183. } );
  184. it( 'should append children', () => {
  185. const count1 = parent.insertChildren( 0, el1 );
  186. const count2 = parent.appendChildren( el2 );
  187. const count3 = parent.appendChildren( el3 );
  188. expect( parent.getChildCount() ).to.equal( 3 );
  189. expect( parent.getChild( 0 ) ).to.have.property( 'name' ).that.equals( 'el1' );
  190. expect( parent.getChild( 1 ) ).to.have.property( 'name' ).that.equals( 'el2' );
  191. expect( parent.getChild( 2 ) ).to.have.property( 'name' ).that.equals( 'el3' );
  192. expect( count1 ).to.equal( 1 );
  193. expect( count2 ).to.equal( 1 );
  194. expect( count3 ).to.equal( 1 );
  195. } );
  196. } );
  197. describe( 'getChildIndex', () => {
  198. it( 'should return child index', () => {
  199. parent.appendChildren( el1 );
  200. parent.appendChildren( el2 );
  201. parent.appendChildren( el3 );
  202. expect( parent.getChildCount() ).to.equal( 3 );
  203. expect( parent.getChildIndex( el1 ) ).to.equal( 0 );
  204. expect( parent.getChildIndex( el2 ) ).to.equal( 1 );
  205. expect( parent.getChildIndex( el3 ) ).to.equal( 2 );
  206. } );
  207. } );
  208. describe( 'getChildren', () => {
  209. it( 'should renturn children iterator', () => {
  210. parent.appendChildren( el1 );
  211. parent.appendChildren( el2 );
  212. parent.appendChildren( el3 );
  213. const expected = [ el1, el2, el3 ];
  214. let i = 0;
  215. for ( let child of parent.getChildren() ) {
  216. expect( child ).to.equal( expected[ i ] );
  217. i++;
  218. }
  219. expect( i ).to.equal( 3 );
  220. } );
  221. } );
  222. describe( 'removeChildren', () => {
  223. it( 'should remove children', () => {
  224. parent.appendChildren( el1 );
  225. parent.appendChildren( el2 );
  226. parent.appendChildren( el3 );
  227. parent.appendChildren( el4 );
  228. parent.removeChildren( 1, 2 );
  229. expect( parent.getChildCount() ).to.equal( 2 );
  230. expect( parent.getChild( 0 ) ).to.have.property( 'name' ).that.equals( 'el1' );
  231. expect( parent.getChild( 1 ) ).to.have.property( 'name' ).that.equals( 'el4' );
  232. expect( el1.parent ).to.equal( parent );
  233. expect( el2.parent ).to.be.null;
  234. expect( el3.parent ).to.be.null;
  235. expect( el4.parent ).equal( parent );
  236. } );
  237. it( 'should remove one child when second parameter is not specified', () => {
  238. parent.appendChildren( el1 );
  239. parent.appendChildren( el2 );
  240. parent.appendChildren( el3 );
  241. const removed = parent.removeChildren( 1 );
  242. expect( parent.getChildCount() ).to.equal( 2 );
  243. expect( parent.getChild( 0 ) ).to.have.property( 'name' ).that.equals( 'el1' );
  244. expect( parent.getChild( 1 ) ).to.have.property( 'name' ).that.equals( 'el3' );
  245. expect( removed.length ).to.equal( 1 );
  246. expect( removed[ 0 ] ).to.have.property( 'name' ).that.equals( 'el2' );
  247. } );
  248. } );
  249. } );
  250. describe( 'attributes manipulation methods', () => {
  251. let el;
  252. beforeEach( () => {
  253. el = new ViewElement( 'p' );
  254. } );
  255. describe( 'setAttribute', () => {
  256. it( 'should set attribute', () => {
  257. el.setAttribute( 'foo', 'bar' );
  258. expect( el._attrs.has( 'foo' ) ).to.be.true;
  259. expect( el._attrs.get( 'foo' ) ).to.equal( 'bar' );
  260. } );
  261. it( 'should set class', () => {
  262. el.setAttribute( 'class', 'foo bar' );
  263. expect( el._attrs.has( 'class' ) ).to.be.false;
  264. expect( el._classes.has( 'foo' ) ).to.be.true;
  265. expect( el._classes.has( 'bar' ) ).to.be.true;
  266. } );
  267. it( 'should replace all existing classes', () => {
  268. el.setAttribute( 'class', 'foo bar baz' );
  269. el.setAttribute( 'class', 'qux' );
  270. expect( el._classes.has( 'foo' ) ).to.be.false;
  271. expect( el._classes.has( 'bar' ) ).to.be.false;
  272. expect( el._classes.has( 'baz' ) ).to.be.false;
  273. expect( el._classes.has( 'qux' ) ).to.be.true;
  274. } );
  275. it( 'should replace all styles', () => {
  276. el.setStyle( 'color', 'red' );
  277. el.setStyle( 'top', '10px' );
  278. el.setAttribute( 'style', 'border:none' );
  279. expect( el.hasStyle( 'color' ) ).to.be.false;
  280. expect( el.hasStyle( 'top' ) ).to.be.false;
  281. expect( el.hasStyle( 'border' ) ).to.be.true;
  282. expect( el.getStyle( 'border' ) ).to.equal( 'none' );
  283. } );
  284. } );
  285. describe( 'getAttribute', () => {
  286. it( 'should return attribute', () => {
  287. el.setAttribute( 'foo', 'bar' );
  288. expect( el.getAttribute( 'foo' ) ).to.equal( 'bar' );
  289. expect( el.getAttribute( 'bom' ) ).to.not.be.ok;
  290. } );
  291. it( 'should return class attribute', () => {
  292. el.addClass( 'foo', 'bar' );
  293. expect( el.getAttribute( 'class' ) ).to.equal( 'foo bar' );
  294. } );
  295. it( 'should return undefined if no class attribute', () => {
  296. expect( el.getAttribute( 'class' ) ).to.be.undefined;
  297. } );
  298. it( 'should return style attribute', () => {
  299. el.setStyle( 'color', 'red' );
  300. el.setStyle( 'top', '10px' );
  301. expect( el.getAttribute( 'style' ) ).to.equal( 'color:red;top:10px;' );
  302. } );
  303. } );
  304. describe( 'hasAttribute', () => {
  305. it( 'should return true if element has attribute', () => {
  306. el.setAttribute( 'foo', 'bar' );
  307. expect( el.hasAttribute( 'foo' ) ).to.be.true;
  308. expect( el.hasAttribute( 'bom' ) ).to.be.false;
  309. } );
  310. it( 'should return true if element has class attribute', () => {
  311. expect( el.hasAttribute( 'class' ) ).to.be.false;
  312. el.addClass( 'foo' );
  313. expect( el.hasAttribute( 'class' ) ).to.be.true;
  314. } );
  315. it( 'should return true if element has style attribute', () => {
  316. expect( el.hasAttribute( 'style' ) ).to.be.false;
  317. el.setStyle( 'border', '1px solid red' );
  318. expect( el.hasAttribute( 'style' ) ).to.be.true;
  319. } );
  320. } );
  321. describe( 'getAttributeKeys', () => {
  322. it( 'should return keys', () => {
  323. el.setAttribute( 'foo', true );
  324. el.setAttribute( 'bar', true );
  325. const expected = [ 'foo', 'bar' ];
  326. let i = 0;
  327. for ( let key of el.getAttributeKeys() ) {
  328. expect( key ).to.equal( expected[ i ] );
  329. i++;
  330. }
  331. expect( i ).to.equal( 2 );
  332. } );
  333. it( 'should return class key', () => {
  334. el.addClass( 'foo' );
  335. el.setAttribute( 'bar', true );
  336. const expected = [ 'class', 'bar' ];
  337. let i = 0;
  338. for ( let key of el.getAttributeKeys() ) {
  339. expect( key ).to.equal( expected[ i ] );
  340. i++;
  341. }
  342. } );
  343. it( 'should return style key', () => {
  344. el.setStyle( 'color', 'black' );
  345. el.setAttribute( 'bar', true );
  346. const expected = [ 'style', 'bar' ];
  347. let i = 0;
  348. for ( let key of el.getAttributeKeys() ) {
  349. expect( key ).to.equal( expected[ i ] );
  350. i++;
  351. }
  352. } );
  353. } );
  354. describe( 'removeAttribute', () => {
  355. it( 'should remove attributes', () => {
  356. el.setAttribute( 'foo', true );
  357. expect( el.hasAttribute( 'foo' ) ).to.be.true;
  358. el.removeAttribute( 'foo' );
  359. expect( el.hasAttribute( 'foo' ) ).to.be.false;
  360. expect( utils.count( el.getAttributeKeys() ) ).to.equal( 0 );
  361. } );
  362. it( 'should remove classe attribute', () => {
  363. el.addClass( 'foo', 'bar' );
  364. el.removeAttribute( 'class' );
  365. expect( el.hasAttribute( 'class' ) ).to.be.false;
  366. expect( el.hasClass( 'foo' ) ).to.be.false;
  367. expect( el.hasClass( 'bar' ) ).to.be.false;
  368. } );
  369. // it( 'should fire event', () => {
  370. //
  371. // } );
  372. } );
  373. } );
  374. describe( 'addClass', () => {
  375. it( 'should add single class', () => {
  376. const el = new ViewElement( 'foo' );
  377. el.addClass( 'one' );
  378. expect( el._classes.has( 'one' ) ).to.be.true;
  379. } );
  380. it( 'should add multiple classes', () => {
  381. const el = new ViewElement( 'foo' );
  382. el.addClass( 'one', 'two', 'three' );
  383. expect( el._classes.has( 'one' ) ).to.be.true;
  384. expect( el._classes.has( 'two' ) ).to.be.true;
  385. expect( el._classes.has( 'three' ) ).to.be.true;
  386. } );
  387. } );
  388. describe( 'removeClass', () => {
  389. it( 'should remove single class', () => {
  390. const el = new ViewElement( 'foo', { class: 'one two three' } );
  391. el.removeClass( 'one' );
  392. expect( el._classes.has( 'one' ) ).to.be.false;
  393. expect( el._classes.has( 'two' ) ).to.be.true;
  394. expect( el._classes.has( 'three' ) ).to.be.true;
  395. } );
  396. it( 'should remove multiple classes', () => {
  397. const el = new ViewElement( 'foo', { class: 'one two three four' } );
  398. el.removeClass( 'one', 'two', 'three' );
  399. expect( el._classes.has( 'one' ) ).to.be.false;
  400. expect( el._classes.has( 'two' ) ).to.be.false;
  401. expect( el._classes.has( 'three' ) ).to.be.false;
  402. expect( el._classes.has( 'four' ) ).to.be.true;
  403. } );
  404. } );
  405. describe( 'hasClass', () => {
  406. it( 'should check if element has a class', () => {
  407. const el = new ViewElement( 'foo' );
  408. el.addClass( 'one', 'two', 'three' );
  409. expect( el.hasClass( 'one' ) ).to.be.true;
  410. expect( el.hasClass( 'two' ) ).to.be.true;
  411. expect( el.hasClass( 'three' ) ).to.be.true;
  412. expect( el.hasClass( 'four' ) ).to.be.false;
  413. } );
  414. it( 'should check if element has multiple classes', () => {
  415. const el = new ViewElement( 'foo' );
  416. el.addClass( 'one', 'two', 'three' );
  417. expect( el.hasClass( 'one', 'two' ) ).to.be.true;
  418. expect( el.hasClass( 'three', 'two' ) ).to.be.true;
  419. expect( el.hasClass( 'three', 'one', 'two' ) ).to.be.true;
  420. expect( el.hasClass( 'three', 'one', 'two', 'zero' ) ).to.be.false;
  421. } );
  422. } );
  423. describe( 'setStyle', () => {
  424. it( 'should set element style', () => {
  425. const el = new ViewElement( 'p' );
  426. el.setStyle( 'color', 'red' );
  427. expect( el._styles.has( 'color' ) ).to.be.true;
  428. expect( el._styles.get( 'color' ) ).to.equal( 'red' );
  429. } );
  430. } );
  431. describe( 'getStyle', () => {
  432. it( 'should get style', () => {
  433. const el = new ViewElement( 'p' );
  434. el.setStyle( 'color', 'red' );
  435. el.setStyle( 'border', '1px solid red' );
  436. expect( el.getStyle( 'color' ) ).to.equal( 'red' );
  437. expect( el.getStyle( 'border' ) ).to.equal( '1px solid red' );
  438. } );
  439. } );
  440. describe( 'hasStyle', () => {
  441. it( 'should check if element has a style', () => {
  442. const el = new ViewElement( 'p' );
  443. el.setStyle( 'padding-top', '10px' );
  444. expect( el.hasStyle( 'padding-top' ) ).to.be.true;
  445. expect( el.hasStyle( 'padding-left' ) ).to.be.false;
  446. } );
  447. it( 'should check if element has multiple styles', () => {
  448. const el = new ViewElement( 'p' );
  449. el.setStyle( 'padding-top', '10px' );
  450. el.setStyle( 'margin-left', '10px' );
  451. el.setStyle( 'color', '10px;' );
  452. expect( el.hasStyle( 'padding-top', 'margin-left' ) ).to.be.true;
  453. expect( el.hasStyle( 'padding-top', 'margin-left', 'color' ) ).to.be.true;
  454. expect( el.hasStyle( 'padding-top', 'padding-left' ) ).to.be.false;
  455. } );
  456. } );
  457. describe( 'removeStyle', () => {
  458. it( 'should remove style', () => {
  459. const el = new ViewElement();
  460. el.setStyle( 'padding-top', '10px' );
  461. el.removeStyle( 'padding-top' );
  462. expect( el.hasStyle( 'padding-top' ) ).to.be.false;
  463. } );
  464. it( 'should remove multiple styles', () => {
  465. const el = new ViewElement();
  466. el.setStyle( 'padding-top', '10px' );
  467. el.setStyle( 'margin-top', '10px' );
  468. el.setStyle( 'color', 'red' );
  469. el.removeStyle( 'padding-top', 'margin-top' );
  470. expect( el.hasStyle( 'padding-top' ) ).to.be.false;
  471. expect( el.hasStyle( 'margin-top' ) ).to.be.false;
  472. expect( el.hasStyle( 'color' ) ).to.be.true;
  473. } );
  474. } );
  475. } );