The only person responsible for managing your time is you
UML (Unified Modeling Language)
--------------- ---------------
| ClassName | | ClassName |
--------------- ---------------
| Properties | --------> | Properties |
--------------- ---------------
| Methods | | Methods |
--------------- ---------------
John Cleveley's MVCP (Presenter) design
Clients should not be forced to depend on methods that they do not use.
@if $core or $tablet
...or at the very least keeps it encapsulated
$(this).attr('id') => this.id
Encapsulates an algorithm inside a class separating the selection from the implementation
Made up of the following pieces...The Composite Pattern describes a group of objects that can be treated in the same way as a single instance of an object may be.
"unit tests ensure you build the thing right, while acceptance tests ensure you build the right thing"
// Test Suite (i.e. group of related tests)
describe('Acme widget', function(){
// Spec (i.e. individual test)
it('should ...do something', function(){
// Matcher (i.e. assertion API)
expect(true).toBeTruthy();
});
});
expect(x).toBe(y);
expect(x).toBeDefined();
expect(x).toBeTruthy();
expect(x).toContain(y)
expect(x).toBeLessThan(y);
...many more...
expect(x).not.toBe(y);
expect(x).not.toBeDefined();
expect(x).not.toBeTruthy();
expect(x).not.toContain(y)
expect(x).not.toBeLessThan(y);
beforeEach(function(){
this.addMatchers({
toBeArray: function (expected) {
return Object.prototype.toString.call(this.actual) === '[object Array]' ? true : false;
}
});
this.addMatchers({
toBeNumber: function (expected) {
return /\d+/.test(this.actual);
}
});
this.addMatchers({
toBeNaN: function (expected) {
return isNaN(this.actual);
}
});
this.addMatchers({
toBeSameElementAs: function (expected) {
return expected.isEqualNode(this.actual);
}
});
});
He pretended to have deserted the Greeks and, as a Trojan captive, told the Trojans that the giant wooden horse the Greeks had left behind was intended as a gift to the gods to ensure their safe voyage home.
function doSomething(x){ console.log(x); }
window.setTimeout(doSomething, 1000, 'xyz');
this.clock = sinon.useFakeTimers();
this.clock.tick(1000); // trigger code that would've run after 1 sec
this.clock.restore();
this.server = sinon.fakeServer.create();
this.server.respondWith('POST', '/success.json', [200, {}, JSON.stringify({reply: 'success', body: 'test'})]);
this.server.restore();
// instead of...
expect(spy.calledWith('foo')).toBeTruthy();
// you can use...
expect(spy).toHaveBeenCalledWith('foo');
expect(spy).toHaveBeenCalled()
expect(spy).toHaveBeenCalledWith()
expect(spy).toHaveBeenCalledOnce()
expect(spy).toHaveBeenCalledTwice()
expect(spy).toHaveReturned()
...and more...