Skip to content

Instantly share code, notes, and snippets.

@tonini
Created September 25, 2013 08:28
Show Gist options
  • Save tonini/6696690 to your computer and use it in GitHub Desktop.
Save tonini/6696690 to your computer and use it in GitHub Desktop.
context = describe
before = beforeEach
describe "LockIconToggleCtrl", ->
beforeEach(angular.mock.module("test"))
scope = {}
ctrl = {}
beforeEach inject ($controller, $rootScope) ->
scope = $rootScope.$new()
ctrl = $controller("LockIconToggleCtrl", {$scope: scope})
describe '#toggle', ->
it 'Return icon-lock', ->
scope.currentIcon = 'icon-unlock'
expect(scope.toggle()).toEqual('icon-lock')
it 'Return icon-unlock', ->
scope.currentIcon = 'icon-lock'
expect(scope.toggle()).toEqual('icon-unlock')
describe '#isLocked', ->
context 'icon-lock is active', ->
before ->
scope.currentIcon = 'icon-lock'
it 'Return true', ->
expect(scope.isLocked()).toBe(true)
context 'icon-lock is inactive', ->
before ->
scope.currentIcon = 'icon-unlock'
it 'Return false', ->
expect(scope.isLocked()).toBe(false)
describe '#isUnlocked', ->
context 'icon-unlock is active', ->
before ->
scope.currentIcon = 'icon-unlock'
it 'Return true', ->
expect(scope.isUnlocked()).toBe(true)
context 'icon-unlock is inactive', ->
before ->
scope.currentIcon = 'icon-lock'
it 'Return true', ->
expect(scope.isUnlocked()).toBe(false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment