This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //guess where this fails. | |
| this.x = function() { | |
| hello(); | |
| } | |
| (foo || bar).call(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //java | |
| class X extends Y { | |
| public X() { | |
| super(); | |
| } | |
| public void method() { | |
| } | |
| public static staticMethod() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //easy way to check if object has the expected "shape": | |
| it('tests something', function() { | |
| var expectedObject = { | |
| some: 'prop', | |
| values: 'here' | |
| }; | |
| var result = doStuff(); | |
| assert.deepEqual(result, expectedObject); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var moves = [].. | |
| function makeMove() { | |
| var m = moves.shift(); | |
| if(!m) { | |
| return everythingDone(); | |
| } | |
| setTimeout(function() { | |
| activateButton(m); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //let's say all the moves are in this array | |
| var moves = [...]; | |
| moves.reduce(function(p, move) { | |
| return p.then(activateWithDelay(move.button)) | |
| .then(deactivateWithDelay(move.button)); | |
| }, Promise.resolve()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('"moveRight()" should increment the "x" propety by 1', function () { | |
| var blocky = new Block(15, 30); | |
| blocky.moveRight(); | |
| assert.equal(blocky.x, 16); | |
| }); | |
| //....vs.... | |
| it('"moveRight()" should increment the "x" propety by 1', function () { | |
| var startingX = 15; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('Something', function() { | |
| var values = ['a', 'b', 'c']; | |
| values.forEach(function(val) { | |
| it('should do something with ' + val + ' in this test', function() { | |
| assert.equal(foo(), val); | |
| }); | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| someModule.service('something', function($rootScope) { | |
| var emitter = $rootScope.$new(true); | |
| var data = whateverStuffHere; | |
| return { | |
| onDataUpdated: function(callback) { | |
| //by returning the result from $on, we get | |
| //the ability to remove event listeners easily | |
| return emitter.$on('update', callback); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('something', function() { | |
| var oldXrm; | |
| beforeEach(function() { | |
| oldXrm = Xrm; | |
| Xrm = { | |
| Page: { | |
| getAttribute: sinon.stub() | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('something', function() { | |
| var sandbox; | |
| beforeEach(function() { | |
| sandbox = sinon.sandbox.create(); | |
| }); | |
| afterEach(function() { | |
| sandbox.restore(); | |
| }); | |
NewerOlder