Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
781 B

  1. var test = require('tape');
  2. var traverse = require('../');
  3. test('sort test', function (t) {
  4. var acc = [];
  5. traverse({
  6. a: 30,
  7. b: 22,
  8. id: 9
  9. }).forEach(function (node) {
  10. if ((! Array.isArray(node)) && typeof node === 'object') {
  11. this.before(function(node) {
  12. this.keys = Object.keys(node);
  13. this.keys.sort(function(a, b) {
  14. a = [a === "id" ? 0 : 1, a];
  15. b = [b === "id" ? 0 : 1, b];
  16. return a < b ? -1 : a > b ? 1 : 0;
  17. });
  18. });
  19. }
  20. if (this.isLeaf) acc.push(node);
  21. });
  22. t.equal(
  23. acc.join(' '),
  24. '9 30 22',
  25. 'Traversal in a custom order'
  26. );
  27. t.end();
  28. });