Skip to content

Commit

Permalink
rename a function, initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shanzi committed Aug 25, 2015
1 parent c60b131 commit f93b089
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
Expand Up @@ -5,8 +5,6 @@ describe 'changeitem', ->
injected = ($injector) ->
$compile = $injector.get('$compile')
$rootScope = $injector.get('$rootScope')
webSocketService = $injector.get('webSocketService')
spyOn(webSocketService, 'getWebSocket').and.returnValue({})

beforeEach inject injected

Expand Down
Expand Up @@ -23,7 +23,7 @@ class _ForcebuildForm extends Controller
elem.attr(attributes) if attributes
return elem

labelElemnt: (text) ->
labelElement: (text) ->
text = text.trim().replace /:$/, ''
return null if not text
label = @element 'label'
Expand Down Expand Up @@ -101,7 +101,7 @@ class _ForcebuildForm extends Controller
'required': field.required
'ng-model': "form.model.#{ field.name }"
'md-is-error': "form.errors.#{ field.name }"
container.append @labelElemnt field.label
container.append @labelElement field.label
container.append input
elem.append container
return elem
Expand All @@ -113,7 +113,7 @@ class _ForcebuildForm extends Controller
'required': field.required
'ng-model': "form.model.#{ field.name }"
'md-is-error': "form.errors.#{ field.name }"
container.append @labelElemnt field.label
container.append @labelElement field.label
container.append textarea
elem.append container
return elem
Expand All @@ -126,7 +126,7 @@ class _ForcebuildForm extends Controller
'required': field.required
'ng-model': "form.model.#{ field.name }"
'md-is-error': "form.errors.#{ field.name }"
container.append @labelElemnt field.label
container.append @labelElement field.label
container.append input
elem.append container
return elem
Expand All @@ -152,7 +152,7 @@ class _ForcebuildForm extends Controller
f = @element 'md-option', value: choice
f.text(choice)
select.append f
container.append @labelElemnt field.label
container.append @labelElement field.label
container.append select
elem.append container
return elem
Expand Up @@ -2,7 +2,7 @@ beforeEach module 'app'

describe 'forcebuildform', ->

$compile = $rootScope = $httpBackend = dataService = scope = RESULTS_TEXT = null
$compile = $rootScope = $httpBackend = dataService = scope = null
injected = ($injector) ->
$compile = $injector.get('$compile')
$rootScope = $injector.get('$rootScope')
Expand All @@ -14,6 +14,30 @@ describe 'forcebuildform', ->
dataService = $injector.get('dataService')
spyOn(dataService, 'startConsuming').and.returnValue($q.resolve())
scope = $rootScope.$new()
RESULTS_TEXT = $injector.get('RESULTS_TEXT')

beforeEach inject injected

it 'should show fields correctly', ->
$rootScope.fields =
type: 'nested'
layout: 'simple'
fields:[
type: 'int'
label: 'intlabel'
,
type: 'textarea'
label: 'textarealabel'
,
type: 'text'
label: 'textlabel'
,
type: 'bool'
label: 'boollabel'
,
type: 'list'
label: 'listlabel'
choices: ['a', 'b', 'c']
]
$rootScope.data = {}
elem = $compile('<forcebuild-form fields="fields" data="data"></forcebuild-form>')($rootScope)
$rootScope.digest()

0 comments on commit f93b089

Please sign in to comment.