pdf_history_spec.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. 'use strict';
  16. var _pdf_history = require('../../web/pdf_history');
  17. describe('pdf_history', function () {
  18. describe('isDestsEqual', function () {
  19. var firstDest = [{
  20. num: 1,
  21. gen: 0
  22. }, { name: 'XYZ' }, 0, 375, null];
  23. var secondDest = [{
  24. num: 5,
  25. gen: 0
  26. }, { name: 'XYZ' }, 0, 375, null];
  27. var thirdDest = [{
  28. num: 1,
  29. gen: 0
  30. }, { name: 'XYZ' }, 750, 0, null];
  31. var fourthDest = [{
  32. num: 1,
  33. gen: 0
  34. }, { name: 'XYZ' }, 0, 375, 1.0];
  35. var fifthDest = [{
  36. gen: 0,
  37. num: 1
  38. }, { name: 'XYZ' }, 0, 375, null];
  39. it('should reject non-equal destination arrays', function () {
  40. expect((0, _pdf_history.isDestsEqual)(firstDest, undefined)).toEqual(false);
  41. expect((0, _pdf_history.isDestsEqual)(firstDest, [1, 2, 3, 4, 5])).toEqual(false);
  42. expect((0, _pdf_history.isDestsEqual)(firstDest, secondDest)).toEqual(false);
  43. expect((0, _pdf_history.isDestsEqual)(firstDest, thirdDest)).toEqual(false);
  44. expect((0, _pdf_history.isDestsEqual)(firstDest, fourthDest)).toEqual(false);
  45. });
  46. it('should accept equal destination arrays', function () {
  47. expect((0, _pdf_history.isDestsEqual)(firstDest, firstDest)).toEqual(true);
  48. expect((0, _pdf_history.isDestsEqual)(firstDest, fifthDest)).toEqual(true);
  49. var firstDestCopy = firstDest.slice();
  50. expect(firstDest).not.toBe(firstDestCopy);
  51. expect((0, _pdf_history.isDestsEqual)(firstDest, firstDestCopy)).toEqual(true);
  52. });
  53. });
  54. });