queryField.js 923 B

1234567891011121314151617181920212223242526272829303132
  1. define([
  2. "esquery",
  3. "jstestr/assert",
  4. "jstestr/test",
  5. "./fixtures/conditional",
  6. "./fixtures/forLoop",
  7. "./fixtures/simpleFunction",
  8. "./fixtures/simpleProgram"
  9. ], function (esquery, assert, test, conditional, forLoop, simpleFunction, simpleProgram) {
  10. test.defineSuite("Field query", {
  11. "single field": function () {
  12. var matches = esquery(conditional, ".test");
  13. assert.contains([
  14. conditional.body[0].test,
  15. conditional.body[1].test,
  16. conditional.body[1].alternate.test
  17. ], matches);
  18. },
  19. "field sequence": function () {
  20. var matches = esquery(simpleProgram, ".declarations.init");
  21. assert.contains([
  22. simpleProgram.body[0].declarations[0].init,
  23. simpleProgram.body[1].declarations[0].init
  24. ], matches);
  25. }
  26. });
  27. });