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.

29 lines
1016 B

4 years ago
  1. /* global MyCustomLogger, log */
  2. "use strict";
  3. describe("loglevel from a global <script> tag with a custom context", function () {
  4. it("is available globally", function () {
  5. expect(MyCustomLogger).not.toBeUndefined();
  6. });
  7. it("doesn't have log defined globally", function () {
  8. expect(window.log).not.toBeDefined();
  9. });
  10. it("allows setting the logging level", function () {
  11. MyCustomLogger.setLevel(MyCustomLogger.levels.TRACE);
  12. MyCustomLogger.setLevel(MyCustomLogger.levels.DEBUG);
  13. MyCustomLogger.setLevel(MyCustomLogger.levels.INFO);
  14. MyCustomLogger.setLevel(MyCustomLogger.levels.WARN);
  15. MyCustomLogger.setLevel(MyCustomLogger.levels.ERROR);
  16. });
  17. it("successfully logs", function () {
  18. window.console = { "log": jasmine.createSpy("log") };
  19. MyCustomLogger.setLevel(MyCustomLogger.levels.INFO);
  20. MyCustomLogger.info("test message");
  21. expect(console.log).toHaveBeenCalledWith("test message");
  22. });
  23. });