Skip to content

Instantly share code, notes, and snippets.

@brian428
Created September 26, 2012 05:14
Show Gist options
  • Save brian428/3786231 to your computer and use it in GitHub Desktop.
Save brian428/3786231 to your computer and use it in GitHub Desktop.
SpyOn_intercept.coffee
it "should allow setting the current company to be intercepted and altered", ->
store = Deft.ioc.Injector.resolve( "companyStore" )
waitsFor( ( -> store.getCount() > 0 ), "Store data never loaded.", 2000 )
runs( ->
grid = viewController.getCompanyGridPanel()
changedPrice = 12345.67
spyOn( viewController, 'setCurrentCompany').andCallFake( ( company ) ->
originalFunction = @setCurrentCompany.originalValue
company.set( "price", changedPrice )
originalFunction.call( @, company )
)
firstCompany = grid.store.getAt( 0 )
grid.fireEvent( "selectionchange", {}, [ firstCompany ], 0 )
expect( viewController.getCurrentCompany().get( "price" ) ).toBe( changedPrice )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment