-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for existing functionality #9
Conversation
🥇 Reviewers: I'd like feedback and to get this merged sooner than later, as it may influence tests I write elsewhere. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few suggestions 🙂
demo_frame.js
Outdated
@@ -86,11 +88,11 @@ module.exports = function(node){ | |||
} | |||
} | |||
} | |||
return source.trim(); | |||
return (source ? source.trim() : false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d recommend just returning a string, not a string or boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
test/basics/demo-complex.html
Outdated
|
||
<script src="../../node_modules/steal/steal.js" main="@empty" id='demo-source'> | ||
import "can-view-autorender"; | ||
import "can-stache-bindings"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems excessive to bring in so many dependencies for a test. Is this one needed? Are there any others that could be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering the same thing, but I don't know much about CanJS. Can you recommend a better "complex" test to do? I like this one because it takes a second (literally) to load.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can-stache-bindings is for stuff like {prop}="value"
What specifically did you want to test? To me, it looks like “complex” means loading modules with StealJS, so I would probably simplify the file to something like this:
<script src="../../node_modules/steal/steal.js" main="@empty" id='demo-source'>
import stache from "can-stache";
var renderer = stache("<h1>Hello {{subject}}</h1>");
var fragment = renderer({subject: "World"})
document.body.appendChild(fragment)
</script>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a (click)
handler that was causing errors under zombie that I removed, so that explains where the can-stache-bindings
came from. The error had to do with cloneNode
, but don't think that's something we would want to resolve just to support zombie. I took this from the canjs/canjs
repo, so it's a real example, which I thought would be important to include next to the overly simple examples. The deps aren't that big of a burden since they're small and quick to install, and are dev only, but I can certainly simplify it if we're not losing anything beneficial by doing so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change almost exactly as you have it here. Thanks for the snippet.
test.js
Outdated
assert = require('assert'), | ||
Browser = require('zombie'), | ||
express = require('express'), | ||
generate = require('bit-docs-generate-html/generate'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don’t have to change this[1], but I’d recommend keeping variable declarations on separate lines. In this case, it’d be easier to scan through the list if they were formatted the same way and alphabetical.
[1] As far as I can tell, this isn’t covered in jQuery’s style guide… now I see why someone (@andrejewski?) was advocating for stricter guidelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the use of tabs is something I picked from other parts of the bit-docs
codebase, and it is my understanding that it is @justinbmeyer's preference. I personally prefer spaces, but technically these do line up properly with your editor configured properly:
The spacing on GitHub's website could be resolved by adding .editorconfig
.
I thought tabs were desired, and that's why I used them here. I'm fine with changing to using var
on each declaration, replacing tabs with spaces, or adding .editorconfig
.
At the end of the day, these tests do their job, and that's most important! I'll leave this for now, as eventually I imagine we'll run everything through a code formatter anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn’t say anything about using spaces instead of tabs. 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, the odd spacing would stand out as a bigger issue when it comes to "easier to scan through the list if they were formatted the same way", and assumed that's what you meant.
The fact that I'm using tabs instead of spaces is a testament to the fact that I'm not having personal preference about formatting. I will change it however you like, but I was mostly concerned about getting your feedback on the functionality and test coverage!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change made.
Still need to automate npm install, and make work with zombie.
With current commits, assuming you manually run (when running
Perhaps something in steals https://github.com/stealjs/steal/blob/master/ext/npm-load.js It would be nice to have encapsulation of the demo deps, as mentioned in #11. |
@leoj3n Is that blocking this from being merged? If not, will you merge this? |
The latest commits are blocking; I should have made them a separate branch/PR (though, I didn't expect zombie to error after some simple reorganization). I'll back out the commits for isolating demo deps, so that this PR will be merge-able again, and break out that idea into it's own PR. |
Also simplifies the "complex" demo and test. Additionally, moves location of "temp" into test/
@chasenlehara Should be merge-able again now. |
Ok go for it |
Changes some of the code in
demo_frame.js
, most notablyshow
now setsdisplay
to''
instead of'block'
. Shouldn't cause any issues on any of the sites, but that is more correct.The tests should be pretty comprehensive, but could add a test for a more complex example.See
test/basics/demo-complex.html
for an example of a complex demo tag usage.Update: Complex demo tag usage example test has been added.