child_ordering.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use strict';
  2. var test = require('../');
  3. var childRan = false;
  4. test('parent', function (t) {
  5. t.test('child', function (st) {
  6. childRan = true;
  7. st.pass('child ran');
  8. st.end();
  9. });
  10. t.end();
  11. });
  12. test('uncle', function (t) {
  13. t.ok(childRan, 'Child should run before next top-level test');
  14. t.end();
  15. });
  16. var grandParentRan = false;
  17. var parentRan = false;
  18. var grandChildRan = false;
  19. test('grandparent', function (t) {
  20. t.ok(!grandParentRan, 'grand parent ran twice');
  21. grandParentRan = true;
  22. t.test('parent', function (st) {
  23. st.ok(!parentRan, 'parent ran twice');
  24. parentRan = true;
  25. st.test('grandchild', function (s2t) {
  26. s2t.ok(!grandChildRan, 'grand child ran twice');
  27. grandChildRan = true;
  28. s2t.pass('grand child ran');
  29. s2t.end();
  30. });
  31. st.pass('parent ran');
  32. st.end();
  33. });
  34. t.test('other parent', function (st) {
  35. st.ok(parentRan, 'first parent runs before second parent');
  36. st.ok(grandChildRan, 'grandchild runs before second parent');
  37. st.end();
  38. });
  39. t.pass('grandparent ran');
  40. t.end();
  41. });
  42. test('second grandparent', function (t) {
  43. t.ok(grandParentRan, 'grandparent ran');
  44. t.ok(parentRan, 'parent ran');
  45. t.ok(grandChildRan, 'grandchild ran');
  46. t.pass('other grandparent ran');
  47. t.end();
  48. });
  49. // vim: set softtabstop=4 shiftwidth=4: