trimStart_trimEnd.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. WScript.LoadScriptFile("../UnitTestFramework/UnitTestFramework.js");
  6. const tests = [
  7. {
  8. name: "trimLeft is same function as trimStart",
  9. body: function () {
  10. // NOTE: See comments in test/UnitTestFramework/UnitTestFramework.js for more info about what assertions you can use
  11. assert.areEqual(String.prototype.trimLeft, String.prototype.trimStart, "Both trimStart and trimLeft should point to the same function");
  12. }
  13. },
  14. {
  15. name: "trimRight is same function as trimEnd",
  16. body: function () {
  17. assert.areEqual(String.prototype.trimRight, String.prototype.trimEnd, "Both trimRight and trimEnd should point to the same function");
  18. }
  19. },
  20. {
  21. name: "String.prototype.trimLeft.name is changed",
  22. body: function () {
  23. assert.areEqual(String.prototype.trimLeft.name, 'trimStart', "String.prototype.trimLeft.name should be named trimStart");
  24. }
  25. },
  26. {
  27. name: "String.prototype.trimRight.name is changed",
  28. body: function () {
  29. assert.areEqual(String.prototype.trimRight.name, 'trimEnd', "String.prototype.trimRight.name should be named trimEnd");
  30. }
  31. },
  32. {
  33. name: "String.prototype.trimStart.name is consistent",
  34. body: function () {
  35. assert.areEqual(String.prototype.trimStart.name, 'trimStart', "String.prototype.trimLeft.name should be named trimStart");
  36. }
  37. },
  38. {
  39. name: "String.prototype.trimEnd.name is changed",
  40. body: function () {
  41. assert.areEqual(String.prototype.trimEnd.name, 'trimEnd', "String.prototype.trimEnd.name should be named trimEnd");
  42. }
  43. }
  44. ];
  45. // The test runner will pass "-args summary -endargs" to ch, so that "summary" appears as argument [0[] to the script,
  46. // and the following line will then ensure that the test will only display summary output (i.e. "PASS").
  47. testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });