Web Interface For Lite Argus Control modules
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.

64 lines
3.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.test.session.addTest('String', {
  8. name: 'Global String Decorators',
  9. planned: 30,
  10. // 5
  11. test_escape: function(){
  12. Y.Assert.areEqual('', String.escape(''), 'Test with an empty string');
  13. Y.Assert.areEqual('foo', String.escape('foo'), 'Test with an non-empty string, no escape characters');
  14. Y.Assert.areEqual('\\\\', String.escape('\\'), 'Test with a string with a single \\');
  15. Y.Assert.areEqual('\\\'', String.escape('\''), 'Test with a string with a single \'');
  16. Y.Assert.areEqual('\\\'foo\\\\', String.escape('\'foo\\'), 'Test with a mix of escape and non escape characters');
  17. },
  18. // 6
  19. test_format: function(){
  20. Y.Assert.areEqual('foo', String.format('foo'), 'Test with no format parameters, no function parameters');
  21. Y.Assert.areEqual('foo', String.format('foo', 'x'), 'Test with no format parameters, 1 argument parameter');
  22. Y.Assert.areEqual('foo', String.format('{0}', 'foo'), 'Test with only a format parameter');
  23. Y.Assert.areEqual('xyz', String.format('{0}{1}{2}', 'x', 'y', 'z'), 'Test with several format parameters');
  24. Y.Assert.areEqual('xy', String.format('{0}{1}', 'x', 'y', 'z'), 'Test with several format parameters, extra format parameters');
  25. Y.Assert.areEqual('xfooy', String.format('{0}foo{1}', 'x', 'y'), 'Test with a mix of a string and format parameters');
  26. },
  27. // 7
  28. test_leftPad: function(){
  29. Y.Assert.areEqual(' ', String.leftPad('', 5), 'Test with empty string');
  30. Y.Assert.areEqual(' foo', String.leftPad('foo', 5), 'Test with string smaller than the padding size');
  31. Y.Assert.areEqual('foofoo', String.leftPad('foofoo', 5), 'Test with string bigger than the padding size');
  32. Y.Assert.areEqual('foo', String.leftPad('foo', 0), 'Test with a padding size of 0');
  33. Y.Assert.areEqual('foo', String.leftPad('foo', -5), 'Test with a padding size of less than 0');
  34. Y.Assert.areEqual('00000', String.leftPad('', 5, '0'), 'Test with empty string, different padding character');
  35. Y.Assert.areEqual('00foo', String.leftPad('foo', 5, '0'), 'Test with string smaller than the padding size, different padding character');
  36. },
  37. // 2
  38. test_toggle: function(){
  39. Y.Assert.areEqual('foo', 'baz'.toggle('foo', 'bar'), 'Test with a starting string that doesn\'t match either');
  40. Y.Assert.areEqual('bar', 'foo'.toggle('foo', 'bar'), 'Test with a starting string that doesn\'t match either');
  41. },
  42. // 10
  43. test_trim: function(){
  44. Y.Assert.areEqual('', ''.trim(), 'Test with empty string');
  45. Y.Assert.areEqual('foo', 'foo'.trim(), 'Test with string with no whitespace');
  46. Y.Assert.areEqual('', ' '.trim(), 'Test with string with only whitespace');
  47. Y.Assert.areEqual('bar', ' bar '.trim(), 'Test with string with leading and trailing whitespace');
  48. Y.Assert.areEqual('foo', 'foo '.trim(), 'Test with only trailing spaces');
  49. Y.Assert.areEqual('bar', ' bar'.trim(), 'Test with only leading spaces');
  50. Y.Assert.areEqual('foo bar', 'foo bar'.trim(), 'Test with spaces in between words');
  51. Y.Assert.areEqual('foo bar baz', ' foo bar baz '.trim(), 'Test with mixtures of different spaces');
  52. Y.Assert.areEqual('foo', '\tfoo'.trim(), 'Test with tabs, as opposed to spaces');
  53. Y.Assert.areEqual('text', '\ttext '.trim(), 'Test with mixture of spaces and tabs');
  54. }
  55. });