Merge pull request #32 from sharelatex/hof-fix-tk-in-tests

move tk call to before sandboxed module call
This commit is contained in:
James Allen 2018-07-06 09:29:37 +01:00 committed by GitHub
commit a5a2efd3b3
3 changed files with 9 additions and 9 deletions

View file

@ -8,6 +8,7 @@ tk = require "timekeeper"
describe "DocumentManager", ->
beforeEach ->
tk.freeze(new Date())
@DocumentManager = SandboxedModule.require modulePath, requires:
"./RedisManager": @RedisManager = {}
"./ProjectHistoryRedisManager": @ProjectHistoryRedisManager = {}
@ -35,6 +36,9 @@ describe "DocumentManager", ->
@pathname = '/a/b/c.tex'
@unflushedTime = Date.now()
afterEach ->
tk.reset()
describe "flushAndDeleteDoc", ->
describe "successfully", ->
beforeEach ->
@ -394,12 +398,8 @@ describe "DocumentManager", ->
describe "getDocAndFlushIfOld", ->
beforeEach ->
tk.freeze(new Date())
@DocumentManager.flushDocIfLoaded = sinon.stub().callsArg(2)
afterEach ->
tk.reset()
describe "when the doc is in Redis", ->
describe "and has changes to be flushed", ->
beforeEach ->

View file

@ -26,8 +26,8 @@ describe "ProjectHistoryRedisManager", ->
globals:
JSON: @JSON = JSON
afterEach ->
tk.reset()
afterEach ->
tk.reset()
describe "queueOps", ->
beforeEach ->

View file

@ -55,14 +55,14 @@ describe "RedisManager", ->
globals:
JSON: @JSON = JSON
afterEach ->
tk.reset()
@doc_id = "doc-id-123"
@project_id = "project-id-123"
@projectHistoryId = 123
@callback = sinon.stub()
afterEach ->
tk.reset()
describe "getDoc", ->
beforeEach ->
@lines = ["one", "two", "three", "これは"] # include some utf8