@MichalZalecki
$exceptionHandlerProvider $exceptionHandler $httpBackend $interval $log $timeout $rootScope.Scope angular.mock.TzDate angular.mock.dump angular.mock.inject angular.mock.module
$httpBackend
describe 'A suit', ->
arr = null
beforeEach ->
arr = ['super', 'awesome', 'array']
it 'contains spec with an expectation', ->
expect(true).not.toBe false
arr.splice(1, 1) # doesn't really matter
it 'should have an awesome array', ->
expect(arr).toEqual jasmine.any Array
expect(arr.length).toEqual 3
expect(arr).toContain 'awesome'
expect(arr).not.toContain 'it sucks'
# moment-factory.coffee
angular.module 'moment.moment-factory', []
.factory 'moment', ->
window.moment
# moment-factory_test.coffee
describe 'moment', ->
beforeEach module 'moment.moment-factory'
it 'should be moment.js', inject (moment) ->
expect(moment).toEqual jasmine.any Function
expect(moment).toEqual window.moment
# moment-factory_test.coffee
describe 'moment', ->
moment = null
beforeEach module 'moment.moment-factory'
beforeEach inject (_moment_) ->
moment = _moment_
it 'should be moment.js', ->
expect(moment).toEqual jasmine.any Function
expect(moment).toEqual window.moment
# moment-filter.coffee
angular.module 'moment.moment-filter', []
.filter 'moment', [ 'moment', (moment) ->
(input, from, to = 'DD-MM-YYYY') ->
moment(input, from).format(to) ]
# moment-filter_test.coffee
describe 'momentFilter', ->
beforeEach module 'moment'
it '[...] default DD-MM-YYYY format', inject ($filter) ->
expect($filter('moment')('2015-02-23', 'YYYY-MM-DD'))
.toEqual('23-02-2015')
it 'should work with custom formats', inject ($filter) ->
expect($filter('moment')('2015-02-23 10:35',
'YYYY-MM-DD H:mm', 'Ha, Do MMM YY'))
.toEqual('10am, 23rd Feb 15')
describe 'GitHub Repos', ->
textfield = btnGit = repos = msg = null
beforeEach ->
browser.get 'http://localhost:8080/app/#/github-repos'
textfield = element(By.model("user.name"))
btnGit = element(By.css(".btn-default"))
repos = element.all(By.repeater('repo in repos'))
msg = element(By.exactBinding('msg'))
it '[...] find user repos and set the message', ->
textfield.clear().sendKeys 'MichalZalecki'
btnGit.click()
browser.waitForAngular()
expect(repos.count()).toBeGreaterThan(0)
repos.count().then (count) ->
expect(element(By.css('h2')).getText())
.toEqual "Found #{count} repos"
Pytania?
Michał Załęcki
@MichalZalecki
michalzalecki.com
git clone https://github.com/MichalZalecki/anguloffee