ui_utils_spec.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2021 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. "use strict";
  23. var _ui_utils = require("../../web/ui_utils.js");
  24. var _is_node = require("../../shared/is_node.js");
  25. describe("ui_utils", function () {
  26. describe("binary search", function () {
  27. function isTrue(boolean) {
  28. return boolean;
  29. }
  30. function isGreater3(number) {
  31. return number > 3;
  32. }
  33. it("empty array", function () {
  34. expect((0, _ui_utils.binarySearchFirstItem)([], isTrue)).toEqual(0);
  35. });
  36. it("single boolean entry", function () {
  37. expect((0, _ui_utils.binarySearchFirstItem)([false], isTrue)).toEqual(1);
  38. expect((0, _ui_utils.binarySearchFirstItem)([true], isTrue)).toEqual(0);
  39. });
  40. it("three boolean entries", function () {
  41. expect((0, _ui_utils.binarySearchFirstItem)([true, true, true], isTrue)).toEqual(0);
  42. expect((0, _ui_utils.binarySearchFirstItem)([false, true, true], isTrue)).toEqual(1);
  43. expect((0, _ui_utils.binarySearchFirstItem)([false, false, true], isTrue)).toEqual(2);
  44. expect((0, _ui_utils.binarySearchFirstItem)([false, false, false], isTrue)).toEqual(3);
  45. });
  46. it("three numeric entries", function () {
  47. expect((0, _ui_utils.binarySearchFirstItem)([0, 1, 2], isGreater3)).toEqual(3);
  48. expect((0, _ui_utils.binarySearchFirstItem)([2, 3, 4], isGreater3)).toEqual(2);
  49. expect((0, _ui_utils.binarySearchFirstItem)([4, 5, 6], isGreater3)).toEqual(0);
  50. });
  51. });
  52. describe("EventBus", function () {
  53. it("dispatch event", function () {
  54. const eventBus = new _ui_utils.EventBus();
  55. let count = 0;
  56. eventBus.on("test", function (evt) {
  57. expect(evt).toEqual(undefined);
  58. count++;
  59. });
  60. eventBus.dispatch("test");
  61. expect(count).toEqual(1);
  62. });
  63. it("dispatch event with arguments", function () {
  64. const eventBus = new _ui_utils.EventBus();
  65. let count = 0;
  66. eventBus.on("test", function (evt) {
  67. expect(evt).toEqual({
  68. abc: 123
  69. });
  70. count++;
  71. });
  72. eventBus.dispatch("test", {
  73. abc: 123
  74. });
  75. expect(count).toEqual(1);
  76. });
  77. it("dispatch different event", function () {
  78. const eventBus = new _ui_utils.EventBus();
  79. let count = 0;
  80. eventBus.on("test", function () {
  81. count++;
  82. });
  83. eventBus.dispatch("nottest");
  84. expect(count).toEqual(0);
  85. });
  86. it("dispatch event multiple times", function () {
  87. const eventBus = new _ui_utils.EventBus();
  88. let count = 0;
  89. eventBus.dispatch("test");
  90. eventBus.on("test", function () {
  91. count++;
  92. });
  93. eventBus.dispatch("test");
  94. eventBus.dispatch("test");
  95. expect(count).toEqual(2);
  96. });
  97. it("dispatch event to multiple handlers", function () {
  98. const eventBus = new _ui_utils.EventBus();
  99. let count = 0;
  100. eventBus.on("test", function () {
  101. count++;
  102. });
  103. eventBus.on("test", function () {
  104. count++;
  105. });
  106. eventBus.dispatch("test");
  107. expect(count).toEqual(2);
  108. });
  109. it("dispatch to detached", function () {
  110. const eventBus = new _ui_utils.EventBus();
  111. let count = 0;
  112. const listener = function () {
  113. count++;
  114. };
  115. eventBus.on("test", listener);
  116. eventBus.dispatch("test");
  117. eventBus.off("test", listener);
  118. eventBus.dispatch("test");
  119. expect(count).toEqual(1);
  120. });
  121. it("dispatch to wrong detached", function () {
  122. const eventBus = new _ui_utils.EventBus();
  123. let count = 0;
  124. eventBus.on("test", function () {
  125. count++;
  126. });
  127. eventBus.dispatch("test");
  128. eventBus.off("test", function () {
  129. count++;
  130. });
  131. eventBus.dispatch("test");
  132. expect(count).toEqual(2);
  133. });
  134. it("dispatch to detached during handling", function () {
  135. const eventBus = new _ui_utils.EventBus();
  136. let count = 0;
  137. const listener1 = function () {
  138. eventBus.off("test", listener2);
  139. count++;
  140. };
  141. const listener2 = function () {
  142. eventBus.off("test", listener1);
  143. count++;
  144. };
  145. eventBus.on("test", listener1);
  146. eventBus.on("test", listener2);
  147. eventBus.dispatch("test");
  148. eventBus.dispatch("test");
  149. expect(count).toEqual(2);
  150. });
  151. it("dispatch event to handlers with/without 'once' option", function () {
  152. const eventBus = new _ui_utils.EventBus();
  153. let multipleCount = 0,
  154. onceCount = 0;
  155. eventBus.on("test", function () {
  156. multipleCount++;
  157. });
  158. eventBus.on("test", function () {
  159. onceCount++;
  160. }, {
  161. once: true
  162. });
  163. eventBus.dispatch("test");
  164. eventBus.dispatch("test");
  165. eventBus.dispatch("test");
  166. expect(multipleCount).toEqual(3);
  167. expect(onceCount).toEqual(1);
  168. });
  169. it("should not re-dispatch to DOM", async function () {
  170. if (_is_node.isNodeJS) {
  171. pending("Document is not supported in Node.js.");
  172. }
  173. const eventBus = new _ui_utils.EventBus();
  174. let count = 0;
  175. eventBus.on("test", function (evt) {
  176. expect(evt).toEqual(undefined);
  177. count++;
  178. });
  179. function domEventListener() {
  180. expect(false).toEqual(true);
  181. }
  182. document.addEventListener("test", domEventListener);
  183. eventBus.dispatch("test");
  184. await Promise.resolve();
  185. expect(count).toEqual(1);
  186. document.removeEventListener("test", domEventListener);
  187. });
  188. });
  189. describe("isValidRotation", function () {
  190. it("should reject non-integer angles", function () {
  191. expect((0, _ui_utils.isValidRotation)()).toEqual(false);
  192. expect((0, _ui_utils.isValidRotation)(null)).toEqual(false);
  193. expect((0, _ui_utils.isValidRotation)(NaN)).toEqual(false);
  194. expect((0, _ui_utils.isValidRotation)([90])).toEqual(false);
  195. expect((0, _ui_utils.isValidRotation)("90")).toEqual(false);
  196. expect((0, _ui_utils.isValidRotation)(90.5)).toEqual(false);
  197. });
  198. it("should reject non-multiple of 90 degree angles", function () {
  199. expect((0, _ui_utils.isValidRotation)(45)).toEqual(false);
  200. expect((0, _ui_utils.isValidRotation)(-123)).toEqual(false);
  201. });
  202. it("should accept valid angles", function () {
  203. expect((0, _ui_utils.isValidRotation)(0)).toEqual(true);
  204. expect((0, _ui_utils.isValidRotation)(90)).toEqual(true);
  205. expect((0, _ui_utils.isValidRotation)(-270)).toEqual(true);
  206. expect((0, _ui_utils.isValidRotation)(540)).toEqual(true);
  207. });
  208. });
  209. describe("isPortraitOrientation", function () {
  210. it("should be portrait orientation", function () {
  211. expect((0, _ui_utils.isPortraitOrientation)({
  212. width: 200,
  213. height: 400
  214. })).toEqual(true);
  215. expect((0, _ui_utils.isPortraitOrientation)({
  216. width: 500,
  217. height: 500
  218. })).toEqual(true);
  219. });
  220. it("should be landscape orientation", function () {
  221. expect((0, _ui_utils.isPortraitOrientation)({
  222. width: 600,
  223. height: 300
  224. })).toEqual(false);
  225. });
  226. });
  227. describe("waitOnEventOrTimeout", function () {
  228. let eventBus;
  229. beforeAll(function () {
  230. eventBus = new _ui_utils.EventBus();
  231. });
  232. afterAll(function () {
  233. eventBus = null;
  234. });
  235. it("should reject invalid parameters", async function () {
  236. const invalidTarget = (0, _ui_utils.waitOnEventOrTimeout)({
  237. target: "window",
  238. name: "DOMContentLoaded"
  239. }).then(function () {
  240. expect(false).toEqual(true);
  241. }, function (reason) {
  242. expect(reason instanceof Error).toEqual(true);
  243. });
  244. const invalidName = (0, _ui_utils.waitOnEventOrTimeout)({
  245. target: eventBus,
  246. name: ""
  247. }).then(function () {
  248. expect(false).toEqual(true);
  249. }, function (reason) {
  250. expect(reason instanceof Error).toEqual(true);
  251. });
  252. const invalidDelay = (0, _ui_utils.waitOnEventOrTimeout)({
  253. target: eventBus,
  254. name: "pagerendered",
  255. delay: -1000
  256. }).then(function () {
  257. expect(false).toEqual(true);
  258. }, function (reason) {
  259. expect(reason instanceof Error).toEqual(true);
  260. });
  261. await Promise.all([invalidTarget, invalidName, invalidDelay]);
  262. });
  263. it("should resolve on event, using the DOM", async function () {
  264. if (_is_node.isNodeJS) {
  265. pending("Document is not supported in Node.js.");
  266. }
  267. const button = document.createElement("button");
  268. const buttonClicked = (0, _ui_utils.waitOnEventOrTimeout)({
  269. target: button,
  270. name: "click",
  271. delay: 10000
  272. });
  273. button.click();
  274. const type = await buttonClicked;
  275. expect(type).toEqual(_ui_utils.WaitOnType.EVENT);
  276. });
  277. it("should resolve on timeout, using the DOM", async function () {
  278. if (_is_node.isNodeJS) {
  279. pending("Document is not supported in Node.js.");
  280. }
  281. const button = document.createElement("button");
  282. const buttonClicked = (0, _ui_utils.waitOnEventOrTimeout)({
  283. target: button,
  284. name: "click",
  285. delay: 10
  286. });
  287. const type = await buttonClicked;
  288. expect(type).toEqual(_ui_utils.WaitOnType.TIMEOUT);
  289. });
  290. it("should resolve on event, using the EventBus", async function () {
  291. const pageRendered = (0, _ui_utils.waitOnEventOrTimeout)({
  292. target: eventBus,
  293. name: "pagerendered",
  294. delay: 10000
  295. });
  296. eventBus.dispatch("pagerendered");
  297. const type = await pageRendered;
  298. expect(type).toEqual(_ui_utils.WaitOnType.EVENT);
  299. });
  300. it("should resolve on timeout, using the EventBus", async function () {
  301. const pageRendered = (0, _ui_utils.waitOnEventOrTimeout)({
  302. target: eventBus,
  303. name: "pagerendered",
  304. delay: 10
  305. });
  306. const type = await pageRendered;
  307. expect(type).toEqual(_ui_utils.WaitOnType.TIMEOUT);
  308. });
  309. });
  310. describe("getPageSizeInches", function () {
  311. it("gets page size (in inches)", function () {
  312. const page = {
  313. view: [0, 0, 595.28, 841.89],
  314. userUnit: 1.0,
  315. rotate: 0
  316. };
  317. const {
  318. width,
  319. height
  320. } = (0, _ui_utils.getPageSizeInches)(page);
  321. expect(+width.toPrecision(3)).toEqual(8.27);
  322. expect(+height.toPrecision(4)).toEqual(11.69);
  323. });
  324. it("gets page size (in inches), for non-default /Rotate entry", function () {
  325. const pdfPage1 = {
  326. view: [0, 0, 612, 792],
  327. userUnit: 1,
  328. rotate: 0
  329. };
  330. const {
  331. width: width1,
  332. height: height1
  333. } = (0, _ui_utils.getPageSizeInches)(pdfPage1);
  334. expect(width1).toEqual(8.5);
  335. expect(height1).toEqual(11);
  336. const pdfPage2 = {
  337. view: [0, 0, 612, 792],
  338. userUnit: 1,
  339. rotate: 90
  340. };
  341. const {
  342. width: width2,
  343. height: height2
  344. } = (0, _ui_utils.getPageSizeInches)(pdfPage2);
  345. expect(width2).toEqual(11);
  346. expect(height2).toEqual(8.5);
  347. });
  348. });
  349. describe("getVisibleElements", function () {
  350. const BORDER_WIDTH = 9;
  351. const SPACING = 2 * BORDER_WIDTH - 7;
  352. function makePages(lines) {
  353. const result = [];
  354. let lineTop = 0,
  355. id = 0;
  356. for (const line of lines) {
  357. const lineHeight = line.reduce(function (maxHeight, pair) {
  358. return Math.max(maxHeight, pair[1]);
  359. }, 0);
  360. let offsetLeft = -BORDER_WIDTH;
  361. for (const [clientWidth, clientHeight] of line) {
  362. const offsetTop = lineTop + (lineHeight - clientHeight) / 2 - BORDER_WIDTH;
  363. const div = {
  364. offsetLeft,
  365. offsetTop,
  366. clientWidth,
  367. clientHeight,
  368. clientLeft: BORDER_WIDTH,
  369. clientTop: BORDER_WIDTH
  370. };
  371. result.push({
  372. id,
  373. div
  374. });
  375. ++id;
  376. offsetLeft += clientWidth + SPACING;
  377. }
  378. lineTop += lineHeight + SPACING;
  379. }
  380. return result;
  381. }
  382. function slowGetVisibleElements(scroll, pages) {
  383. const views = [];
  384. const {
  385. scrollLeft,
  386. scrollTop
  387. } = scroll;
  388. const scrollRight = scrollLeft + scroll.clientWidth;
  389. const scrollBottom = scrollTop + scroll.clientHeight;
  390. for (const view of pages) {
  391. const {
  392. div
  393. } = view;
  394. const viewLeft = div.offsetLeft + div.clientLeft;
  395. const viewRight = viewLeft + div.clientWidth;
  396. const viewTop = div.offsetTop + div.clientTop;
  397. const viewBottom = viewTop + div.clientHeight;
  398. if (viewLeft < scrollRight && viewRight > scrollLeft && viewTop < scrollBottom && viewBottom > scrollTop) {
  399. const hiddenHeight = Math.max(0, scrollTop - viewTop) + Math.max(0, viewBottom - scrollBottom);
  400. const hiddenWidth = Math.max(0, scrollLeft - viewLeft) + Math.max(0, viewRight - scrollRight);
  401. const fractionHeight = (div.clientHeight - hiddenHeight) / div.clientHeight;
  402. const fractionWidth = (div.clientWidth - hiddenWidth) / div.clientWidth;
  403. const percent = fractionHeight * fractionWidth * 100 | 0;
  404. views.push({
  405. id: view.id,
  406. x: viewLeft,
  407. y: viewTop,
  408. view,
  409. percent,
  410. widthPercent: fractionWidth * 100 | 0
  411. });
  412. }
  413. }
  414. return {
  415. first: views[0],
  416. last: views[views.length - 1],
  417. views
  418. };
  419. }
  420. function scrollOverDocument(pages, horizontal = false, rtl = false) {
  421. const size = pages.reduce(function (max, {
  422. div
  423. }) {
  424. return Math.max(max, horizontal ? Math.abs(div.offsetLeft + div.clientLeft + div.clientWidth) : div.offsetTop + div.clientTop + div.clientHeight);
  425. }, 0);
  426. for (let i = -size; i < size; i += 7) {
  427. for (let j = i + 5; j < size; j += j - i) {
  428. const scrollEl = horizontal ? {
  429. scrollTop: 0,
  430. scrollLeft: i,
  431. clientHeight: 10000,
  432. clientWidth: j - i
  433. } : {
  434. scrollTop: i,
  435. scrollLeft: 0,
  436. clientHeight: j - i,
  437. clientWidth: 10000
  438. };
  439. expect((0, _ui_utils.getVisibleElements)({
  440. scrollEl,
  441. views: pages,
  442. sortByVisibility: false,
  443. horizontal,
  444. rtl
  445. })).toEqual(slowGetVisibleElements(scrollEl, pages));
  446. }
  447. }
  448. }
  449. it("with pages of varying height", function () {
  450. const pages = makePages([[[50, 20], [20, 50]], [[30, 12], [12, 30]], [[20, 50], [50, 20]], [[50, 20], [20, 50]]]);
  451. scrollOverDocument(pages);
  452. });
  453. it("widescreen challenge", function () {
  454. const pages = makePages([[[10, 50], [10, 60], [10, 70], [10, 80], [10, 90]], [[10, 90], [10, 80], [10, 70], [10, 60], [10, 50]], [[10, 50], [10, 60], [10, 70], [10, 80], [10, 90]]]);
  455. scrollOverDocument(pages);
  456. });
  457. it("works with horizontal scrolling", function () {
  458. const pages = makePages([[[10, 50], [20, 20], [30, 10]]]);
  459. scrollOverDocument(pages, true);
  460. });
  461. it("works with horizontal scrolling with RTL-documents", function () {
  462. const pages = makePages([[[-10, 50], [-20, 20], [-30, 10]]]);
  463. scrollOverDocument(pages, true, true);
  464. });
  465. it("handles `sortByVisibility` correctly", function () {
  466. const scrollEl = {
  467. scrollTop: 75,
  468. scrollLeft: 0,
  469. clientHeight: 750,
  470. clientWidth: 1500
  471. };
  472. const views = makePages([[[100, 150]], [[100, 150]], [[100, 150]]]);
  473. const visible = (0, _ui_utils.getVisibleElements)({
  474. scrollEl,
  475. views
  476. });
  477. const visibleSorted = (0, _ui_utils.getVisibleElements)({
  478. scrollEl,
  479. views,
  480. sortByVisibility: true
  481. });
  482. const viewsOrder = [],
  483. viewsSortedOrder = [];
  484. for (const view of visible.views) {
  485. viewsOrder.push(view.id);
  486. }
  487. for (const view of visibleSorted.views) {
  488. viewsSortedOrder.push(view.id);
  489. }
  490. expect(viewsOrder).toEqual([0, 1, 2]);
  491. expect(viewsSortedOrder).toEqual([1, 2, 0]);
  492. });
  493. it("handles views being empty", function () {
  494. const scrollEl = {
  495. scrollTop: 10,
  496. scrollLeft: 0,
  497. clientHeight: 750,
  498. clientWidth: 1500
  499. };
  500. const views = [];
  501. expect((0, _ui_utils.getVisibleElements)({
  502. scrollEl,
  503. views
  504. })).toEqual({
  505. first: undefined,
  506. last: undefined,
  507. views: []
  508. });
  509. });
  510. it("handles all views being hidden (without errors)", function () {
  511. const scrollEl = {
  512. scrollTop: 100000,
  513. scrollLeft: 0,
  514. clientHeight: 750,
  515. clientWidth: 1500
  516. };
  517. const views = makePages([[[100, 150]], [[100, 150]], [[100, 150]]]);
  518. expect((0, _ui_utils.getVisibleElements)({
  519. scrollEl,
  520. views
  521. })).toEqual({
  522. first: undefined,
  523. last: undefined,
  524. views: []
  525. });
  526. });
  527. describe("backtrackBeforeAllVisibleElements", function () {
  528. const tallPage = [10, 50];
  529. const shortPage = [10, 10];
  530. const top1 = 20 + SPACING + 40;
  531. const top2 = 20 + SPACING + 10;
  532. it("handles case 1", function () {
  533. const pages = makePages([[[10, 20], [10, 20], [10, 20], [10, 20]], [tallPage, shortPage, tallPage, shortPage], [[10, 50], [10, 50], [10, 50], [10, 50]], [[10, 20], [10, 20], [10, 20], [10, 20]], [[10, 20]]]);
  534. const bsResult = 4;
  535. expect((0, _ui_utils.backtrackBeforeAllVisibleElements)(bsResult, pages, top1)).toEqual(4);
  536. });
  537. it("handles case 2", function () {
  538. const pages = makePages([[[10, 20], [10, 20], [10, 20], [10, 20]], [tallPage, shortPage, tallPage, tallPage], [[10, 50], [10, 50], [10, 50], [10, 50]], [[10, 20], [10, 20], [10, 20], [10, 20]]]);
  539. const bsResult = 6;
  540. expect((0, _ui_utils.backtrackBeforeAllVisibleElements)(bsResult, pages, top1)).toEqual(4);
  541. });
  542. it("handles case 3", function () {
  543. const pages = makePages([[[10, 20], [10, 20], [10, 20], [10, 20]], [tallPage, shortPage, tallPage, shortPage], [[10, 50], [10, 50], [10, 50], [10, 50]], [[10, 20], [10, 20], [10, 20], [10, 20]]]);
  544. const bsResult = 8;
  545. expect((0, _ui_utils.backtrackBeforeAllVisibleElements)(bsResult, pages, top1)).toEqual(4);
  546. });
  547. it("handles case 4", function () {
  548. const pages = makePages([[[10, 20], [10, 20], [10, 20], [10, 20]], [tallPage, shortPage, tallPage, shortPage], [[10, 50], [10, 50], [10, 50], [10, 50]], [[10, 20], [10, 20], [10, 20], [10, 20]]]);
  549. const bsResult = 4;
  550. expect((0, _ui_utils.backtrackBeforeAllVisibleElements)(bsResult, pages, top2)).toEqual(4);
  551. });
  552. });
  553. });
  554. describe("moveToEndOfArray", function () {
  555. it("works on empty arrays", function () {
  556. const data = [];
  557. (0, _ui_utils.moveToEndOfArray)(data, function () {});
  558. expect(data).toEqual([]);
  559. });
  560. it("works when moving everything", function () {
  561. const data = [1, 2, 3, 4, 5];
  562. (0, _ui_utils.moveToEndOfArray)(data, function () {
  563. return true;
  564. });
  565. expect(data).toEqual([1, 2, 3, 4, 5]);
  566. });
  567. it("works when moving some things", function () {
  568. const data = [1, 2, 3, 4, 5];
  569. (0, _ui_utils.moveToEndOfArray)(data, function (x) {
  570. return x % 2 === 0;
  571. });
  572. expect(data).toEqual([1, 3, 5, 2, 4]);
  573. });
  574. it("works when moving one thing", function () {
  575. const data = [1, 2, 3, 4, 5];
  576. (0, _ui_utils.moveToEndOfArray)(data, function (x) {
  577. return x === 1;
  578. });
  579. expect(data).toEqual([2, 3, 4, 5, 1]);
  580. });
  581. it("works when moving nothing", function () {
  582. const data = [1, 2, 3, 4, 5];
  583. (0, _ui_utils.moveToEndOfArray)(data, function (x) {
  584. return x === 0;
  585. });
  586. expect(data).toEqual([1, 2, 3, 4, 5]);
  587. });
  588. });
  589. });