mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Don't rely on specific time in EditorStats spec
This commit is contained in:
@@ -2,7 +2,7 @@ module.exports =
|
||||
class StatsTracker
|
||||
startDate: new Date
|
||||
hours: 6
|
||||
eventLog: []
|
||||
eventLog: {}
|
||||
|
||||
constructor: ->
|
||||
date = new Date(@startDate)
|
||||
@@ -16,7 +16,7 @@ class StatsTracker
|
||||
rootView.on 'mouseup', => @track()
|
||||
|
||||
clear: ->
|
||||
@eventLog = []
|
||||
@eventLog = {}
|
||||
|
||||
track: ->
|
||||
date = new Date
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
RootView = require 'root-view'
|
||||
EditorStats = require 'editor-stats/lib/editor-stats-view'
|
||||
|
||||
describe "EditorStats", ->
|
||||
[editorStats, time] = []
|
||||
[editorStats] = []
|
||||
|
||||
simulateKeyUp = (key) ->
|
||||
e = $.Event "keydown", keyCode: key.charCodeAt(0)
|
||||
@@ -16,26 +17,22 @@ describe "EditorStats", ->
|
||||
beforeEach ->
|
||||
window.rootView = new RootView
|
||||
rootView.open('sample.js')
|
||||
|
||||
date = new Date()
|
||||
mins = date.getMinutes()
|
||||
hours = date.getHours()
|
||||
|
||||
mins = if mins == 60 then '01' else mins + 1
|
||||
time = "#{hours}:#{mins}"
|
||||
|
||||
editorStats = window.loadPackage('editor-stats').packageMain.stats
|
||||
|
||||
describe "when a keyup event is triggered", ->
|
||||
beforeEach ->
|
||||
expect(_.values(editorStats.eventLog)).not.toContain 1
|
||||
expect(_.values(editorStats.eventLog)).not.toContain 2
|
||||
|
||||
it "records the number of times a keyup is triggered", ->
|
||||
simulateKeyUp('a')
|
||||
expect(editorStats.eventLog[time]).toBe 1
|
||||
expect(_.values(editorStats.eventLog)).toContain 1
|
||||
simulateKeyUp('b')
|
||||
expect(editorStats.eventLog[time]).toBe 2
|
||||
expect(_.values(editorStats.eventLog)).toContain 2
|
||||
|
||||
describe "when a mouseup event is triggered", ->
|
||||
it "records the number of times a mouseup is triggered", ->
|
||||
simulateClick()
|
||||
expect(editorStats.eventLog[time]).toBe 1
|
||||
expect(_.values(editorStats.eventLog)).toContain 1
|
||||
simulateClick()
|
||||
expect(editorStats.eventLog[time]).toBe 2
|
||||
expect(_.values(editorStats.eventLog)).toContain 2
|
||||
|
||||
Reference in New Issue
Block a user