Skip to content

Commit

Permalink
fix(CrowdStrike#281): rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalBryxi committed Jan 23, 2021
1 parent 671ae88 commit 164789f
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions packages/mocha/src/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,24 @@ const {
const { wrap } = require('./mocha');

function roles(getRole, getFilePathTitle) {
return describe => {
return mocha => {
return function roles(...args) {
let callback = args.pop();

let roles = [];
if (args.length > 1) { // roles as multiple arguments
roles = args;
} else if (typeof args[0] === 'string' || args[0] instanceof String) { // roles as concatenated string
} else if (typeof args[0] === 'string' || arguments[0] instanceof String) { // roles as concatenated string
// must be instanced and not inline
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec#Finding_successive_matches
let regex = /(?:^| )#([^ ]+)/g;
let matches = args[0].matchAll(regex);
roles = [...matches].map(i => i[1]);
}

function loopRoles() {
for (let role of roles) {
describe(`#${role}`, function() {
before(function() {
return mocha => {
return function roles(tags, callback) {
// must be instanced and not inline
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec#Finding_successive_matches
let regex = /(?:^| )#([^ ]+)/g;

function loopRoles() {
// eslint-disable-next-line no-cond-assign
for (let matches; matches = regex.exec(tags);) {
let role = matches[1];

for (let role of roles) {
mocha.describe(`#${role}`, function() {
global.before(function() {
this.role = getRole(role);
Expand Down

0 comments on commit 164789f

Please sign in to comment.