Created
October 3, 2017 19:41
-
-
Save MartijnHols/69e5dae5cd08a4f6a28e8a552cefab41 to your computer and use it in GitHub Desktop.
oldCooldownUsable.test.js
This file contains 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
import SPELLS from 'common/SPELLS'; | |
import CooldownUsable from './CooldownUsable'; | |
describe('Core/Modules/CooldownUsable', () => { | |
let instance; | |
let combatantsMock; | |
let castEfficiencyMock; | |
let hasteMock; | |
beforeEach(() => { | |
// Reset mocks: | |
combatantsMock = { | |
selected: { | |
}, | |
}; | |
castEfficiencyMock = { | |
constructor: { | |
CPM_ABILITIES: [], | |
}, | |
}; | |
hasteMock = { | |
current: 0, | |
}; | |
instance = new CooldownUsable({ | |
toPlayer: () => true, | |
byPlayer: () => true, | |
toPlayerPet: () => false, | |
byPlayerPet: () => false, | |
}, { | |
combatants: combatantsMock, | |
castEfficiency: castEfficiencyMock, | |
haste: hasteMock, | |
}); | |
}); | |
it('calculates the cooldown duration using the cooldown calculation set in Cast Efficiency to calculate the cooldown', () => { | |
const getCooldown = jest.fn(); | |
castEfficiencyMock.constructor.CPM_ABILITIES = [ | |
{ | |
spell: SPELLS.HOLY_SHOCK_CAST, | |
getCooldown, | |
}, | |
]; | |
instance.getExpectedCooldownDuration(SPELLS.HOLY_SHOCK_CAST.id); | |
expect(getCooldown).toHaveBeenCalledWith(hasteMock.current, combatantsMock.selected); | |
}); | |
it('calculates the cooldown duration using the current Haste value to calculate the cooldown', () => { | |
const getCooldown = jest.fn(); | |
castEfficiencyMock.constructor.CPM_ABILITIES = [ | |
{ | |
spell: SPELLS.HOLY_SHOCK_CAST, | |
getCooldown, | |
}, | |
]; | |
hasteMock.current = 0; | |
instance.getExpectedCooldownDuration(SPELLS.HOLY_SHOCK_CAST.id); | |
expect(getCooldown.mock.calls[getCooldown.mock.calls.length - 1][0]).toBe(0); | |
hasteMock.current = 0.12; | |
instance.getExpectedCooldownDuration(SPELLS.HOLY_SHOCK_CAST.id); | |
expect(getCooldown.mock.calls[getCooldown.mock.calls.length - 1][0]).toBe(0.12); | |
hasteMock.current = 0.5; | |
instance.getExpectedCooldownDuration(SPELLS.HOLY_SHOCK_CAST.id); | |
expect(getCooldown.mock.calls[getCooldown.mock.calls.length - 1][0]).toBe(0.5); | |
}); | |
it('returns the cooldown duration provided by Cast Efficiency in milliseconds', () => { | |
castEfficiencyMock.constructor.CPM_ABILITIES = [ | |
{ | |
spell: SPELLS.HOLY_SHOCK_CAST, | |
getCooldown: () => 8.4, | |
}, | |
]; | |
expect(instance.getExpectedCooldownDuration(SPELLS.HOLY_SHOCK_CAST.id)).toBe(8400); | |
}); | |
it('ignores inactive spells', () => { | |
const getCooldown = jest.fn(); | |
castEfficiencyMock.constructor.CPM_ABILITIES = [ | |
{ | |
spell: SPELLS.HOLY_SHOCK_CAST, | |
getCooldown: () => 8.4, | |
isActive: () => false, | |
}, | |
{ | |
spell: SPELLS.HOLY_SHOCK_CAST, | |
getCooldown, | |
isActive: () => true, | |
}, | |
]; | |
instance.getExpectedCooldownDuration(SPELLS.HOLY_SHOCK_CAST.id); | |
expect(getCooldown).toHaveBeenCalled(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment