TextMatchExpression_test.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "use strict";
  2. var assert = require('assert'),
  3. TextMatchExpression = require('../../../../lib/pipeline/matcher/TextMatchExpression.js'),
  4. MatchDetails = require('../../../../lib/pipeline/matcher/MatchDetails.js');
  5. module.exports = {
  6. 'TextMatchExpression': {
  7. 'Should match an element, regardless of what is provided.': function() {
  8. var text = new TextMatchExpression(),
  9. text2 = new TextMatchExpression();
  10. assert.strictEqual(text.init('query', 'language').code, 'OK');
  11. assert.strictEqual(text2.init('query2', 'language2').code, 'OK');
  12. assert.ok(text.matchesSingleElement(text2)); // It'll always work. Just the way it is in source.
  13. },
  14. 'Should return the query provided in the init.': function() {
  15. var text = new TextMatchExpression();
  16. text.init('query', 'language');
  17. assert.strictEqual(text.getQuery(), 'query');
  18. },
  19. 'Should return the language provided in the init.': function() {
  20. var text = new TextMatchExpression();
  21. text.init('query', 'language');
  22. assert.strictEqual(text.getLanguage(), 'language');
  23. },
  24. 'Should return equivalency.': function() {
  25. var text1 = new TextMatchExpression(),
  26. text2 = new TextMatchExpression(),
  27. text3 = new TextMatchExpression();
  28. text1.init('query', 'language');
  29. text2.init('query', 'language');
  30. text3.init('query2', 'language2');
  31. assert.ok(text1.equivalent(text1));
  32. assert.ok(text1.equivalent(text2));
  33. assert.ok(!text1.equivalent(text3));
  34. },
  35. 'Should return a shallow copy of the original text match expression.': function() {
  36. var text1 = new TextMatchExpression(),
  37. status = text1.init('query', 'language'),
  38. text2 = text1.shallowClone();
  39. assert.ok(text1.equivalent(text2));
  40. }
  41. }
  42. };
  43. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);