Comments (9)
@gatukgl yes I think you should initilize your own assets.js
file before starting your test. Like you can have a test asset folder;
test-assets/
- asset1.png
- asset2.png
- ...
Thank you can initilize the node index test-assets/ assets.js
Then you can use the assets.js file that you generated for your tests.
from pre-require.
I just have an idea to separate both search()
and format()
in index.js
to be real functions (not just a plain text) so we can easily write unit tests. Would you mind if I open a new issue to refactor that two? :D
So it will looks like below.
// index.js
...
let assetsFileContent = `// import this file for static assets
let Obj = {
${slugArray.join(', ')},
search: ${searchFile},
format: ${searchFileFormat}
}
export default Obj;
`;
...
const searchFile = function(key) {
if(this.hasOwnProperty(key)) {
return this[key];
} else {
return -1;
}
}
const searchFileFormat = function(extension) {
let filteredArray = this.filter(assetSlug => (assetSlug.includes("-"+extention)));
if(filteredArray.length){
return filteredArray;
} else {
return -1;
}
}
from pre-require.
I'm working on it. 🎉
from pre-require.
@gatukgl that's great, if you have any question with the usage cases you can ask in this issue.
from pre-require.
@btk I wonder, to test .format
and .search
function. Is that ok to test on assets.js
file?
from pre-require.
@gatukgl yeah, that is actually really smart!
How do you plan to get them functions into text so the generated file will be as intended? Your current code, (I'm not sure but) ${searchFile}
won't work? Maybe you can use something like function.prototype.toString()
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString
If you can manage the "real" functions to be printed in the assets.js as intended, I would love to see your pr. Thank you.
from pre-require.
Great!! I’ll try :) Thank you.
from pre-require.
@btk I've already opened PR to test .search()
and I'm just curious, for the .filter()
in .format()
, does it work with an object?
from pre-require.
Handled by #31
We might have a new issue to list other possible test cases to be implemented in future. Thank you.
from pre-require.
Related Issues (11)
- Adding -h info. HOT 1
- Built-in asset search HOT 10
- Choosing the type of the asset HOT 3
- Documentation update for new changes HOT 4
- Check English grammar of readme file HOT 3
- Separate search and format text to be real function HOT 3
- Select asset files recursively HOT 7
- Writing tests for loopDirectory HOT 2
- Documentation improvements for recursive file system HOT 2
- Development Section in Documentation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pre-require.