Explorar o código

move tk call to before sandboxed module call

Hayden Faulds %!s(int64=8) %!d(string=hai) anos
pai
achega
0bb37d4991

+ 1 - 1
services/web/test/unit/coffee/Authentication/AuthenticationControllerTests.coffee

@@ -12,6 +12,7 @@ ObjectId = require("mongojs").ObjectId
 
 describe "AuthenticationController", ->
 	beforeEach ->
+		tk.freeze(Date.now())
 		@AuthenticationController = SandboxedModule.require modulePath, requires:
 			"./AuthenticationManager": @AuthenticationManager = {}
 			"../User/UserGetter" : @UserGetter = {}
@@ -39,7 +40,6 @@ describe "AuthenticationController", ->
 		@req = new MockRequest()
 		@res = new MockResponse()
 		@callback = @next = sinon.stub()
-		tk.freeze(Date.now())
 
 	afterEach ->
 		tk.reset()

+ 1 - 1
services/web/test/unit/coffee/History/RestoreManagerTests.coffee

@@ -10,6 +10,7 @@ moment = require('moment')
 
 describe 'RestoreManager', ->
 	beforeEach ->
+		tk.freeze Date.now() # freeze the time for these tests
 		@RestoreManager = SandboxedModule.require modulePath, requires:
 			'../../infrastructure/FileWriter': @FileWriter = {}
 			'../Uploads/FileSystemImportManager': @FileSystemImportManager = {}
@@ -22,7 +23,6 @@ describe 'RestoreManager', ->
 		@project_id = 'mock-project-id'
 		@version = 42
 		@callback = sinon.stub()
-		tk.freeze Date.now() # freeze the time for these tests
 
 	afterEach ->
 		tk.reset()

+ 5 - 6
services/web/test/unit/coffee/Subscription/RecurlyWrapperTests.coffee

@@ -116,6 +116,7 @@ describe "RecurlyWrapper", ->
 					apiKey: 'nonsense'
 					privateKey: 'private_nonsense'
 
+		tk.freeze Date.now() # freeze the time for these tests
 		@RecurlyWrapper = RecurlyWrapper = SandboxedModule.require modulePath, requires:
 			"settings-sharelatex": @settings
 			"logger-sharelatex":
@@ -124,10 +125,11 @@ describe "RecurlyWrapper", ->
 				log:   sinon.stub()
 			"request": sinon.stub()
 
-	describe "sign", ->
+	after ->
+		tk.reset()
 
+	describe "sign", ->
 		before (done) ->
-			tk.freeze Date.now() # freeze the time for these tests
 			@RecurlyWrapper.sign({
 				subscription :
 					plan_code : "gold"
@@ -137,9 +139,6 @@ describe "RecurlyWrapper", ->
 				done()
 			)
 
-		after ->
-			tk.reset()
-
 		it "should be signed correctly", ->
 			signed = @signature.split("|")[0]
 			query = @signature.split("|")[1]
@@ -1061,4 +1060,4 @@ describe "RecurlyWrapper", ->
 				@RecurlyWrapper.listAccountActiveSubscriptions @user_id, @callback
 
 			it "should return an empty array of subscriptions", ->
-				@callback.calledWith(null, []).should.equal true
+				@callback.calledWith(null, []).should.equal true