@bigbinary/neeto-commons-frontend 2.1.36 → 2.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # neeto-commons-frontend
2
2
 
3
3
  A library that packages common boilerplate frontend code necessary for all neeto
4
- products.
4
+ products. Try out the utility functions live at [neetoCommons REPL](https://neeto-cist.neeto.com/).
5
5
 
6
6
  <table>
7
7
  <thead>
@@ -133,6 +133,14 @@ var joinHyphenCase = function joinHyphenCase() {
133
133
  }
134
134
  return args.join(" ").replace(/\s+/g, "-").toLowerCase();
135
135
  };
136
+ var hyphenize = function hyphenize(input) {
137
+ var fallbackString = "";
138
+ if (typeof input === "number") return String(input);
139
+ if (input && typeof input === "string" && input.replace) {
140
+ return input.replace(/[\s_]/g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").replace(/-+/g, "-").toLowerCase();
141
+ }
142
+ return fallbackString;
143
+ };
136
144
  var initializeCredentials = function initializeCredentials(stagingData) {
137
145
  cy.task("getGlobalState").then(function (state) {
138
146
  var newState = _objectSpread$2(_objectSpread$2({}, state), {}, {
@@ -196,7 +204,7 @@ var commonSelectors = {
196
204
  paneHeader: ".neeto-ui-pane__header",
197
205
  profileSidebar: ".neeto-ui-profile-sidebar",
198
206
  selectOption: function selectOption(label) {
199
- return dataCy("".concat(joinHyphenCase(label), "-select-option"));
207
+ return dataCy("".concat(hyphenize(label), "-select-option"));
200
208
  },
201
209
  toastMessage: dataCy("toastr-message-container"),
202
210
  toastCloseButton: ".neeto-ui-toastr__close-button",
@@ -366,7 +374,7 @@ var initCustomCommands = function initCustomCommands() {
366
374
  });
367
375
  Cypress.Commands.add("selectOption", function (containerSelector, optionText) {
368
376
  cy.get(containerSelector).click().type(optionText);
369
- cy.get(commonSelectors.selectOption(optionText.split("_").join("-").toLowerCase())).invoke("click");
377
+ cy.get(commonSelectors.selectOption(optionText)).invoke("click");
370
378
  });
371
379
  Cypress.Commands.add("clickDropdownOption", function (optionText) {
372
380
  var dropdownSelector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : commonSelectors.dropdownIcon;
@@ -1739,6 +1747,7 @@ exports.getTestTitle = getTestTitle;
1739
1747
  exports.getUrl = getUrl;
1740
1748
  exports.helpIconSelectors = helpIconSelectors;
1741
1749
  exports.helpIconTexts = helpIconTexts;
1750
+ exports.hyphenize = hyphenize;
1742
1751
  exports.initCustomCommands = initCustomCommands;
1743
1752
  exports.initializeCredentials = initializeCredentials;
1744
1753
  exports.isStagingEnv = isStagingEnv;