Cypress spy method on page component - vue.js

What I'm trying to do here is simple : I have and filter method called "search()" that is called on different action on my page.
I'd like to "spy" this method and then check if it was called with : cy.get('method').should('be.called')
But really, I don't understand how to reach the method, that is written in one of my component as vue method and spy on it. I've read the docs, but still can't understand how to do this.
Thanks in advance.

This did the trick for me:
mount(Component, opts)
cy.spy(Component.methods, 'method').as('method')
cy.get('#method').should('have.been.calledOnce')

Related

How do you close a vue-material md-menu?

I'd like to call close on a mouseleave event on an md-menu component. I'm using version 0.7.4 of the vue-materiallibrary, and using this documentation it says that there is a close method.
How do I call this method? I've tried the following:
<md-menu md-size="1" ref="aRef" id="aRef">
<div #mouseleave="this.$refs['aRef'].close()">
...other stuff...
</md-menu>
When I run this I get an error saying:
Uncaught TypeError: Cannot read property 'aRef' of undefined
I'm guessing this is something to do with the component not being available at creation time. What's the correct way of doing this?
I should say that the md-menu is actually nested inside another md-menu (which seems to work ok from a functional perspective). Not sure if that screws up the event hierarchy.
I stumbled across the solution for this one while I was trying to solve a different problem (how to close any other menus before opening another).
Your problem is that you can't use this inline in the html template. You need to send the event to a method and then call it...
<md-menu
ref="aRef"
#mouseleave="closeMenu"
>
// menu contents
</md-menu>
Then in your script section:
methods: {
closeMenu() {
this.$refs['aRef'].close();
}
}

Aurelia routing to the same moduleID

Hi there I have asked this on Gitter, but hope that someone here may be able to help.
I have two different routes that have the same moduleId. I have also set up a setting object within the routes with some data to differentiate what gets rendered. Everything works fine when I navigate to one of these routes from somewhere else, but if I navigate from one to the other neither the constructor or the activate are fired. am i missing something??
I had this problem and it took me a while to find a solution - this should help you I hope;
You need to add the determineActivationStrategy() method into your class, and then return as below.
import {activationStrategy} from "aurelia-router";
export class ExampleViewModel {
determineActivationStrategy() {
return activationStrategy.replace;
}
}
This will force the VM to be replaced when you're routing to it from itself.
Here's some more info on the different Activation Strategy types;
activationStrategy.no-change – reuse instance with no lifecycle events
activationStrategy.invokeLifecycle – call lifecycle methods on the ViewModel instance each time the route switches
activationStrategy.replace – construct new instance of ViewModel and invoke full lifecycle on it
Taken from here ZombieCodeKill - Aurelia Routing Beyond the Basics
Found the answer here :) Although not a complete fix out of the box, the implementation is possible

Polymer 1.0: I need a working example of <google-signin-aware>

Question:
Can someone please provide a working code example of how to use <google-signin-aware>?
I have a custom <paper-button> I'm trying to make a login button for Google.
Here is the user documentation.
Here is the Github repository.
Probably the best example for using google-signin-aware is the google-signin element itself.
Essentially what you have to do is to include google-signin-aware with the required attributes and then call the signIn method on this element.
<google-signin-aware
id="aware"
client-id="..."
scopes="..."
...
is-authorized="{{isAuthorized}}"
></google-signin-aware>
<paper-button on-tap="_signIn">Sign In</paper-button>
_signIn: function () {
this.$.aware.signIn();
}

Override a method in dojo - dojo.store.Memory

Is there a way how to run my own function before a dojo method is spawned?
Specifically I need to refresh data in dojo.store.Memory before query() function is spawned. My idea is to put there a callback (that will be spawned before query()), fetch new data from server and then set the data to Memory instance. Then just call
this.inherited(arguments)
I've tried override query method with declare, but I'm still getting some unrelated errors. 4 hours but no luck...
Is there a another way?
Thanks
Yes, you can fire callbacks before, after or around any method. Just use dojo/aspect
Something like this should work :
require(["dojo/store/Memory", "dojo/aspect"], function(Memory, aspect){
aspect.before(Memory, "query", function(){
// do something
});
});
However, for your specific use case, if I understood correctly, what you want is to have a store linked to a server-side controller. In that case, you should use dojo/store/JsonRest rather than dojo/store/Memory. No need to fire any methods before the query...

Where are all my methods of NavigationService and NavigationContext?

I can't see my Navigate method or for that matter any method of NavigationService and NavigationContext of System.Windows.Navigation. The intellisense doesn't show up. I can see only two method named Equals and ReferenceEquals. This looks very funny. What did i do wrong?
Is intellisense broken in general, or is it just not working for Navigation framework?
Will your code compile with the Navigation code in it?