Skip to content

Commit

Permalink
fix: make getTime a free function
Browse files Browse the repository at this point in the history
Removes unused getTime spy
  • Loading branch information
aminya committed Dec 29, 2020
1 parent 2f9392a commit ebf816a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
24 changes: 12 additions & 12 deletions lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -1326,16 +1326,6 @@ class MinimapElement {
}
}

/**
* A method that return the current time as a Date.
*
* That method exist so that we can mock it in tests.
*
* @return {Date} the current time as Date
* @access private
*/
getTime () { return new Date() }

/**
* A method that mimic the jQuery `animate` method and used to animate the
* scroll when clicking on the MinimapElement canvas.
Expand All @@ -1348,7 +1338,7 @@ class MinimapElement {
* @access private
*/
animate ({ from, to, duration, step }) {
const start = this.getTime()
const start = getTime()
let progress

const swing = function (progress) {
Expand All @@ -1358,7 +1348,7 @@ class MinimapElement {
const update = () => {
if (!this.minimap) { return }

const passed = this.getTime() - start
const passed = getTime() - start
if (duration === 0) {
progress = 1
} else {
Expand All @@ -1378,3 +1368,13 @@ class MinimapElement {

const minimapElement = MinimapElement.initClass()
export default minimapElement

/**
* A method that return the current time as a Date.
*
* That method exist so that we can mock it in tests.
*
* @return {Date} the current time as Date
* @access private
*/
function getTime () { return new Date() }
19 changes: 0 additions & 19 deletions spec/minimap-element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,6 @@ describe('MinimapElement', () => {
let canvas

beforeEach(() => {
let t = 0
spyOn(minimapElement, 'getTime').andCallFake(() => {
const n = t
t += 100
return n
})
spyOn(minimapElement, 'requestUpdate').andCallFake(() => {})

atom.config.set('minimap.scrollAnimation', false)
Expand Down Expand Up @@ -828,12 +822,6 @@ describe('MinimapElement', () => {
let canvas

beforeEach(() => {
let t = 0
spyOn(minimapElement, 'getTime').andCallFake(() => {
const n = t
t += 100
return n
})
spyOn(minimapElement, 'requestUpdate').andCallFake(() => {})

atom.config.set('minimap.scrollAnimation', true)
Expand Down Expand Up @@ -1137,13 +1125,6 @@ describe('MinimapElement', () => {
describe('pressing the mouse on the minimap canvas', () => {
beforeEach(() => {
jasmineContent.appendChild(minimapElement)

let t = 0
spyOn(minimapElement, 'getTime').andCallFake(() => {
const n = t
t += 100
return n
})
spyOn(minimapElement, 'requestUpdate').andCallFake(() => {})

atom.config.set('minimap.scrollAnimation', false)
Expand Down

0 comments on commit ebf816a

Please sign in to comment.