variable_specs.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
  2. import {containsVariable} from '../variable';
  3. describe('containsVariable', function() {
  4. describe('when checking if a string contains a variable', function() {
  5. it('should find it with $var syntax', function() {
  6. var contains = containsVariable('this.$test.filters', 'test');
  7. expect(contains).to.be(true);
  8. });
  9. it('should not find it if only part matches with $var syntax', function() {
  10. var contains = containsVariable('this.$ServerDomain.filters', 'Server');
  11. expect(contains).to.be(false);
  12. });
  13. it('should find it with [[var]] syntax', function() {
  14. var contains = containsVariable('this.[[test]].filters', 'test');
  15. expect(contains).to.be(true);
  16. });
  17. it('should find it when part of segment', function() {
  18. var contains = containsVariable('metrics.$env.$group-*', 'group');
  19. expect(contains).to.be(true);
  20. });
  21. it('should find it its the only thing', function() {
  22. var contains = containsVariable('$env', 'env');
  23. expect(contains).to.be(true);
  24. });
  25. it('should be able to pass in multiple test strings', function() {
  26. var contains = containsVariable('asd','asd2.$env', 'env');
  27. expect(contains).to.be(true);
  28. });
  29. });
  30. });