Skip to content

Instantly share code, notes, and snippets.

@brian428
brian428 / CompanyStore.coffee
Created September 6, 2012 05:19
Store method
###*
* Filter the Companies using the specified industry value.
* @param value The industry to filter on.
###
filterIndustry: ( value ) ->
@filter( "industry", value )
@brian428
brian428 / MainController.coffee
Created September 6, 2012 05:18
Controller method
###*
* Update the title for one of the tab panels
* @param title The new title for the panel.
###
updatePanelTitle: ( title ) ->
@getPanel2().title = title
@brian428
brian428 / app_jasmine.coffee
Created September 6, 2012 05:08
ExtJS app config file for Jasmine tests
Ext.Loader.setConfig( enabled: true )
Ext.application
autoCreateViewport: false
name: "JasmineExample"
launch: ->
# Create a reference to the ExtJS Application object so we can perform tests against it.
window.Application = @
@brian428
brian428 / MainTabPanelTest.coffee
Created September 6, 2012 04:17
Spec involving asynchronous behavior and testing a non-view object
it "allows store to be filtered", ->
# We can test methods on a non-view object, including tests that involve asynchronous activities.
# This really doesn't belong in the MainTabPanelTest, but for simplicty I'm including it here.
store = Deft.ioc.Injector.resolve( "companyStore" )
waitsFor( ( -> store.getCount() > 0 ), "Store data never loaded.", 2000 )
runs( ->
expect( store.filters.length ).toBe( 0 )
store.filterIndustry( "Manufacturing" )
@brian428
brian428 / MainTabPanelTest.coffee
Created September 6, 2012 04:16
Spec that tests a view controller method
it "allows panel title to be changed", ->
# We can test a ViewController method after the view is rendered and associated view controller configured.
expect( viewController.getPanel2().title ).toEqual( "Panel 2" )
viewController.updatePanelTitle( "My New Title" )
expect( viewController.getPanel2().title ).toEqual( "My New Title" )
@brian428
brian428 / MainTabPanelTest.coffee
Created September 6, 2012 04:15
Spec that tests basic view and view controller creation
describe "During a successful startup...", ->
it "has created the main tab panel view and view controller", ->
expect( view ).toBeDefined()
expect( view.rendered ).toBeTruthy()
expect( view instanceof JasmineExample.view.MainTabPanel ).toBeTruthy()
expect( viewController ).toBeDefined()
expect( viewController instanceof JasmineExample.controller.MainController ).toBeTruthy()
expect( viewController.getView() is view ).toBeTruthy()
@brian428
brian428 / MainTabPanelTest.coffee
Created September 6, 2012 04:13
Setup for a more complex spec
describe "The Main Tab Panel...", ->
view = null
viewController = null
# A hidden div where we can add UI components to test them and their dependencies.
createComponentTestArea = ->
if Ext.get( "componentTestArea" )? then Ext.removeNode( Ext.get( "componentTestArea" ).dom )
Ext.DomHelper.append( Ext.getBody(), "<div id='componentTestArea' style='visibility: hidden'></div>" )
@brian428
brian428 / BasicTest.coffee
Created September 6, 2012 04:12
Basic Jasmine Test
describe "During initialization and setup, the application...", ->
it "has loaded ExtJS 4", ->
expect( Ext ).toBeDefined()
expect( Ext.getVersion() ).toBeTruthy()
expect( Ext.getVersion().major ).toEqual( 4 )
it "has loaded Application with expected Application name", ->
@brian428
brian428 / gist:3507343
Created August 29, 2012 06:09
Running parameterized batch file
"C:\Developer\Tools\javascript\common\build\coffee\coffeescript parameterized watcher.bat" ^
C:\Developer\Tools\Tomcat\7.0.12\tests\webapps\tests\extexamples/coffee ^
C:\Developer\Tools\Tomcat\7.0.12\tests\webapps\tests\extexamples/app
@brian428
brian428 / gist:3507287
Created August 29, 2012 05:56
Running parameterized Cakefile
cake ^
-s C:\Developer\Tools\Tomcat\7.0.12\tests\webapps\tests\extexamples/coffee ^
-o C:\Developer\Tools\Tomcat\7.0.12\tests\webapps\tests\extexamples/app ^
watchany