Skip to content
This repository has been archived by the owner on Dec 27, 2018. It is now read-only.

Stubs does not work correctly on Assets api inside a method call #17

Open
kelbongoo opened this issue Sep 28, 2015 · 2 comments
Open

Stubs does not work correctly on Assets api inside a method call #17

kelbongoo opened this issue Sep 28, 2015 · 2 comments

Comments

@kelbongoo
Copy link

I tried using stubs to stub a call to Assets.getText, but it doesn't seem to work. Using latest Jasmine server integration on meteor 1.2.0.1.

describe('hello test', function(){
    beforeAll(function(){
        stubs.create('getText', Assets, 'getText');
        stubs.getText.returns('<div>Foo bar</div>');
    });
    describe('a test', function(){
        console.log('Assets.getText', Assets.getText('foo')); // works here - returns '<div>Foo bar</div>'
        myMethods['testMethod']();
    });
});

myMethods = {
    testMethod : function(){
         console.log('stubs.getText', stubs.getText); // correct value here
        console.log('Assets.getText', Assets.getText('foo')); // INCORRECT - uses original Assets.getText
    }
};

so the correct stubs.getText is available inside the method, but it does not actually stub Assets.getText...

@rbabayoff
Copy link
Member

@kelbongoo do you mean velocity jasmine? If yes, I think he already provides mocks for the entire meteor API, so that might be the reason it won't work. Otherwise, try to create the stub inside the test method and see if it works.

@kelbongoo
Copy link
Author

@rbabayoff yes velocity jasmine in server integration mode so Meteor API is not mocked. Console.log of Assets inside the method shows it is the usual Meteor Assets API there. Will try to create the stub in the method and get back to you...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants