Skip to content

Commit

Permalink
Rework test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dompuiu committed Oct 23, 2018
1 parent 309bb17 commit 58a3316
Show file tree
Hide file tree
Showing 4 changed files with 819 additions and 529 deletions.
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"trailingComma": "none",
"singleQuote": true
}
44 changes: 44 additions & 0 deletions src/__tests__/helpers/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = {
extensionName: 'test-extension',
toCamelCase: function(str) {
return str
.replace(/(?:^\w|[A-Z]|\b\w)/g, function(letter, index) {
return index === 0 ? letter.toLowerCase() : letter.toUpperCase();
})
.replace(/\s+/g, '');
},
toSnakeCase: function toSnakeCase(str) {
if (!str) return '';

return String(str)
.replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')
.replace(/([a-z])([A-Z])/g, function(m, a, b) {
return a + '-' + b.toLowerCase();
})
.replace(/[^A-Za-z0-9]+|_-+/g, '-')
.toLowerCase();
},

createModule: function(name, scriptFn) {
var cName = this.toCamelCase(name);
var sName = this.toSnakeCase(name);

return [
this.getPath(cName),
{
name: sName,
displayName: name,
script: scriptFn
},
this.extensionName
];
},

getPath: function(name) {
return this.extensionName + '/' + this.toCamelCase(name) + '.js';
},

getType: function(name) {
return this.extensionName + '.' + this.toSnakeCase(name);
}
};
Loading

0 comments on commit 58a3316

Please sign in to comment.