I want to find these components using Enzyme's find() facility:
<PaneWrapper data-pane="...">
<PaneWorkspaceSearch data-pane="...">
I'm currently trying this pattern, but Enzyme does not recognise it:
wrapper.find('PaneWrapper[data-pane], PaneWorkspaceSearch[data-pane]');
Any ideas?
I’d suggest using .findWhere and providing a function predicate rather than relying on string selectors here, since enzyme doesn’t yet support multiple complex selectors.
Related
Tailwind offers a feature where you can give an input element the peer class and then, in a sibling element use the peer-invalid: pseudoclass to apply conditional stylings. This is commonly used to provide helper text when a form field is not valid.
I don't see how this can be tested in JS-DOM though, as JS-DOM doesn't have access to the actual CSS when it is just rendering components in unit tests.
The information I have seen about getting JS-DOM to use CSS at all is kinda sketchy, so I was wondering if it's even worth trying to get it to evaluate a bunch of tailwind classes in a NextJS/Jest/RTL project. I'm using Tailwind 3 so it's not even like I have a big file full of generated classes I could try and pass to JS-DOM :/
So can it be done? (Note the hard fact please mods!!!)
(And, somewhat more subjectively, should it be done? Or is there a better way to approach this?)
I'm trying to query solr through haystack for all objects that either does not have an attribute (it's Null) or the attribute is a specified value.
I can query solr directly with the snippet (brand:foo OR (*:* -brand:*)) and get what I want. But I can't find a way to formulate this or anything logically the same through haystack without really ugly hacks.
I did find this ugly hack:
SearchQuerySet().filter(brand=Raw('%s OR (*:* -brand:*)' % Clean('foo'))
But it chains really poorly with that OR in there without any parenthesis around it.
Ideally a solution using a pure filter would be best, but failing that a way to add a chainable filter using raw solr query language.
I'm using django-haystack 2.4.0
It's not a perfect match, but narrow helps me enough to let me do what I want
SearchQuerySet().narrow('(brand:%s OR (*:* -brand:*))' % Clean('foo'))
I have a couple of functions that use jQuery. And I'm having trouble making sense of the proper way to test them with jQuery-Chai in Mocha+Chai.
I see the list of assertions in the jQuery-Chai plugin. However, I don't understand where we get the DOM data to run those assertions?
Ideally I want to insert a line of html. Run the function on it. And use the jQuery-Chai assertion to validate.
Can someone help clear up where I would include the fixture to test these functions?
Thanks in advance.
Using: Testem with Mocha+Chai.
As you noted, chai-jquery only provides the assertions you can use against DOM elements. You'll need to use a different library to actually populate the DOM. Since you already need jQuery included for chai-jquery to work, the simplest solution may be to use jQuery's append() function to add child elements to the DOM, then remove them at the end of the test using jQuery's remove() function.
Alternatively, if you want to abstract away the DOM manipulation a bit, you could try pulling in a fixtures library. My favorite for this purpose is js-fixtures. You can still easily insert a single line of html using the set() function if that's all you need:
fixtures.set('<div>Your html here</div>');
If your test html becomes more complex though, you can extract it out into a sample html file and load the entirety of it into the DOM with the load() function:
fixtures.load('yourTestPage.html');
Finally, when your test is finished, you can easily clean your fixture using fixtures.cleanUp().
I'd like to pass some parameters to Solr that should afflict the weighting of the results (I do not want to filter away results that do not match these criterias).
E.g. I'd like to have a language attribute, and if i pass the user's language to the search engine I'd like to have the results matching the language listed first. As a newbie to Solr I'd like to know if and how this is possible!
Yes, that's possible by using boost functions. See this FAQ entry or the description of boost functions for the DisMaxQueryPlugin (the dismax query parser is the default parser).
Was wondering if there's anything like ruby's .send for htmlbars. Been trying to search for it, but can't seem to find a proper answer. Here's what I want to do:
{{"name-of-helper" arguments}}
As simple as this. Is there any trick under it to achieve this effect?
There is no built-in one or supplemented one but if you need it you can write one for yourself.
Ember includes "component" helper which allows you to dynamically build component - it's not exactly the same, but might suit your needs.