array.test.js 1.1 KB

123456789101112131415161718192021222324252627
  1. "use strict";
  2. exports.__esModule = true;
  3. var array_js_1 = require("../array.js");
  4. describe('next-sitemap/array', function () {
  5. test('toChunks', function () {
  6. var inputArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  7. var chunkSize = 3;
  8. var chunks = (0, array_js_1.toChunks)(inputArray, chunkSize);
  9. expect(chunks).toStrictEqual([
  10. [0, 1, 2],
  11. [3, 4, 5],
  12. [6, 7, 8],
  13. [9, 10],
  14. ]);
  15. });
  16. test('toArray', function () {
  17. expect((0, array_js_1.toArray)('hello')).toStrictEqual(['hello']);
  18. expect((0, array_js_1.toArray)(['hello', 'world'])).toStrictEqual(['hello', 'world']);
  19. });
  20. test('removeFromArray', function () {
  21. expect((0, array_js_1.removeFromArray)([1, 2, 3], [2])).toStrictEqual([1, 3]);
  22. expect((0, array_js_1.removeFromArray)([1, 2, 3], [2, 3, 4])).toStrictEqual([1]);
  23. });
  24. test('removeIfMatchPattern', function () {
  25. expect((0, array_js_1.removeIfMatchPattern)(['/hello', '/world', '/something'], ['/hello*', '/som*'])).toStrictEqual(['/world']);
  26. });
  27. });