Michał Załęcki
@MichalZalecki
michalzalecki.com
foo = (txt) -> "#{txt} bar"
str = foo "Foo"
obj =
foo: 1
bar: 2
var foo, obj, str;
foo = function(txt) {
return "" + txt + " bar";
};
str = foo("Foo");
obj = {
foo: 1,
bar: 2
};
class Person
constructor: (@name) ->
sayHi: ->
"#{@name} is saying hi!"
foo = new Person "Foo"
bar = new Person "Bar"
alert foo.sayHi()
alert bar.sayHi()
var Person, bar, foo;
Person = (function() {
function Person(name) {
this.name = name;
}
Person.prototype.sayHi =
function() {
return "" + this.name +
" is saying hi!";
};
return Person;
})();
foo = new Person("Foo");
bar = new Person("Bar");
alert(foo.sayHi());
alert(bar.sayHi());
describe 'A suit', ->
arr = null
beforeEach ->
arr = ['super', 'awesome', 'array']
it 'contains spec with an expectation', ->
expect(true).toBe true
expect(true).not.toBe false
arr.splice(1, 1) # doesn't really matter
it 'should have awesome array', ->
expect(arr).toEqual jasmine.any Array
expect(arr).toContain 'awesome'
expect(arr).not.toContain 'it sucks'
'use strict'
describe 'moment.moment-factory', ->
moment = null
beforeEach module 'moment.moment-factory'
beforeEach inject (_moment_) ->
moment = _moment_
it 'shoud be windows.moment', ->
expect(moment).toEqual window.moment
expect(moment).toEqual jasmine.any(Function)
describe 'Demo page', ->
beforeEach ->
browser.get 'http://testing-angularjs-michalrazorzalecki.c9.io/app/'
it 'should have a title', ->
expect(browser.getTitle())
.toEqual 'Testing AngularJS with Jasmine and CoffeeScript'
it 'should have 5 .alert', ->
expect(element.all(By.css '.alert').count()).toBe 5
it 'should have .alert .close button which can close the alert', ->
alertDism = element.all By.css '.alert-dismissible'
expect(alertDism.count()).toBeGreaterThan 0
element.all(By.css '.alert .close').click()
expect(alertDism.count()).toBe 0
git clone --depth=1 https://github.com/MichalZalecki/anguloffee