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
'use strict'; | |
const chai = require('chai'); | |
const sinon = require('sinon'); | |
chai.use(require('sinon-chai')); | |
const expect = chai.expect; | |
const sandbox = sinon.createSandbox(); |
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('A person', () => { | |
it('Has all the right properties and values', () => { | |
expect(person).to.be.an('object').and.have.keys('guid', 'name', 'company', 'email', 'phone', | |
'isActive', 'age', 'gender'); | |
expect(person.guid).to.equal('79c936b0-c75f-4b09-b53e-8d7822bbe17b'); | |
expect(person.name).to.equal('Mcguire English'); | |
expect(person.company).to.equal('ZILLAR'); | |
expect(person.email).to.equal('[email protected]'); | |
expect(person.phone).to.equal('+1 (555) 555-5555'); | |
expect(person.isActive).to.equal(true); |
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('A person', () => { | |
it('Has all the right properties and values', () => { | |
expect(person).to.be.deep.equal({ | |
guid: '79c936b0-c75f-4b09-b53e-8d7822bbe17b', | |
name: 'Mcguire English', | |
company: 'ZILLAR', | |
email: '[email protected]', | |
phone: '+1 (555) 555-5555', | |
isActive: false, | |
age: 35, |
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
const lorem = { | |
ipsum: { | |
dolor: { | |
sit: 'amet' | |
} | |
} | |
}; | |
const foo = { | |
ipsum: { |
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
const lorem = { | |
ipsum: { | |
dolor: { | |
sit: 'amet' | |
} | |
} | |
}; | |
const foo = { | |
bar: 'baz' |
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
'use strict'; | |
const express = require('express'); | |
const recycle = require('pending-promise-recycler'); | |
const server = express(); | |
const someSlowAndExpensiveOperation = function () { | |
return new Promise((resolve, reject) => { | |
console.log('Starting a very slow operation!') |
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
'use strict'; | |
const express = require('express'); | |
const recycle = require('pending-promise-recycler'); | |
const server = express(); | |
const someSlowAndExpensiveOperation = function () { | |
return new Promise((resolve, reject) => { | |
console.log('Starting a very slow operation!') |
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
const fetchSomethingExpensive = (arg1, arg2) => { | |
return new Promise(resolve => { | |
// Assume there is a call to a 3rd party API here -it will take ~300 ms. to respond | |
setTimeout(() => { | |
resolve({ foo: 'bar' }); | |
}, 300); | |
}); | |
}; |
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
/** | |
* Calculates the damage of a melee attack. | |
* | |
* @param {object} weapon - Weapon used in the attack. | |
* @param {object} interactives - Interactive creatures involved in the melee attack. | |
* @param {object} interactives.attacker - Player who inflicts the attack. | |
* @param {object} [interactives.defender] - Player who inflicts the attack. | |
* @param {object} [options] - Options of this function. | |
* @param {boolean} [options.inflictInDefender=false] - Whether to actually inflict the damage on <code>defender</code>. | |
* @param {boolean} [options.ignoreMagicalResistance=false] - If <code>true</code> magical resistances will be ignored in the calculations. |
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
/** | |
* Calculates the damage of a melee attack. | |
* | |
* @param {object} weapon - Weapon used in the attack. | |
* @param {object} interactives - Interactive creatures involved in the melee attack. | |
* @param {object} interactives.attacker - Player who inflicts the attack. | |
* @param {object} [interactives.defender] - Player who inflicts the attack. | |
* @param {object} options - Options of this function. | |
* @param {boolean} [options.inflictInDefender=false] - Whether to actually inflict the damage on <code>defender</code>. | |
* @param {boolean} [options.ignoreMagicalResistance=false] - If <code>true</code> magical resistances will be ignored in the calculations. |
NewerOlder