-
Notifications
You must be signed in to change notification settings - Fork 175
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
plugin tests need improvements #543
Labels
Comments
That second thing is exactly why I created urlPlugin, to simplify that! You're right about the first one as well, we need to improve our tests. |
I've addressed your second part, making urlPlugin more convenient, in #547 |
Looks good for me! |
👍 cool! |
vivien
added a commit
to vivien/glowing-bear
that referenced
this issue
Feb 8, 2015
Extend UrlPlugin to take an optional regexp pattern, and pass the matches array to the plugin callback. This allows to factorize the case insensitivity ('i' flag), and get rid of redundant match check in plugins: var regexp = /.../; var match = url.match(regexp); if (match) { ... } Refs glowing-bear#543 (part 3)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
plugin tests don't support multiple matches
The following line:
will embbed 2 Youtube videos. However, adding this line to the test cases will fail.
Plugin tests don't check output
Tests must be extended to also check the expected output. If you're regex has multiple matches and you made the mistake to return the bad index (let's say
undefined
), the test will still pass.For instance, try the following patch:
Note on regexp
Plugins must be written in the way that they support multiple contents per line.
We might want to impose the following regexp syntax:
/https?:\/\/(www\.)?foobar?/g
please note the global
g
flag and no line delimiters (^
or$
).Also, the plugin code must be written like
while (match) { content.push(); } return content;
(see the youtube plugin or the Vine plugin).Maybe this peace of code can be factorized which would allow to only provide the regexp portion to compile and the expected output. For instance:
The text was updated successfully, but these errors were encountered: