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.

71 lines
2.3 KiB

4 years ago
  1. "use strict";
  2. define(['../lib/loglevel', 'test/test-helpers'], function(log, testHelpers) {
  3. var describeIf = testHelpers.describeIf;
  4. var itIf = testHelpers.itIf;
  5. describe("Integration smoke tests:", function() {
  6. describe("log methods", function() {
  7. it("can all be disabled", function() {
  8. log.setLevel(log.levels.SILENT);
  9. log.trace("trace");
  10. log.debug("debug");
  11. log.log("log");
  12. log.info("info");
  13. log.warn("warn");
  14. log.error("error");
  15. });
  16. });
  17. describeIf(typeof console !== "undefined", "log methods", function() {
  18. it("can all be called", function() {
  19. if (typeof console !== "undefined") {
  20. log.setLevel(log.levels.TRACE);
  21. }
  22. log.trace("trace");
  23. log.debug("debug");
  24. log.log("log");
  25. log.info("info");
  26. log.warn("warn");
  27. log.error("error");
  28. });
  29. });
  30. describeIf(typeof console !== "undefined", "log levels", function() {
  31. beforeEach(function() {
  32. this.addMatchers({
  33. "toBeTheStoredLevel" : testHelpers.toBeTheStoredLevel
  34. });
  35. });
  36. it("are all settable", function() {
  37. log.setLevel(log.levels.TRACE);
  38. log.setLevel(log.levels.DEBUG);
  39. log.setLevel(log.levels.INFO);
  40. log.setLevel(log.levels.WARN);
  41. log.setLevel(log.levels.ERROR);
  42. });
  43. itIf(testHelpers.isAnyLevelStoragePossible(), "are persisted", function() {
  44. log.setLevel(log.levels.TRACE);
  45. expect('trace').toBeTheStoredLevel();
  46. log.setLevel(log.levels.DEBUG);
  47. expect('debug').toBeTheStoredLevel();
  48. log.setLevel(log.levels.INFO);
  49. expect('info').toBeTheStoredLevel();
  50. log.setLevel(log.levels.WARN);
  51. expect('warn').toBeTheStoredLevel();
  52. log.setLevel(log.levels.ERROR);
  53. expect('error').toBeTheStoredLevel();
  54. log.setLevel(log.levels.SILENT);
  55. expect('silent').toBeTheStoredLevel();
  56. });
  57. });
  58. });
  59. });