helpers.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. /**
  4. * Helpers for defining commands more quickly.
  5. *
  6. * In this file we define some helpers for quickly defining commands with either do nothing,
  7. * set/get a value on the session, or return a constant value.
  8. */
  9. const selenium_mock_1 = require("selenium-mock");
  10. function noopFactory(path, method = 'POST') {
  11. return new selenium_mock_1.Command(method, path, () => { });
  12. }
  13. exports.noopFactory = noopFactory;
  14. function getterFactory(path, name, method = 'GET') {
  15. name = name || path.split('/').pop();
  16. return new selenium_mock_1.Command(method, path, (session) => {
  17. return session[name];
  18. });
  19. }
  20. exports.getterFactory = getterFactory;
  21. function setterFactory(path, name, paramName) {
  22. name = name || path.split('/').pop();
  23. paramName = paramName || name;
  24. return new selenium_mock_1.Command('POST', path, (session, params) => {
  25. session[name] = params[paramName];
  26. });
  27. }
  28. exports.setterFactory = setterFactory;
  29. function constFactory(method, path, val) {
  30. return new selenium_mock_1.Command(method, path, () => {
  31. return val;
  32. });
  33. }
  34. exports.constFactory = constFactory;
  35. //# sourceMappingURL=helpers.js.map