Henry Oswald 8 лет назад
Родитель
Сommit
2168f20715

+ 218 - 218
services/clsi/test/acceptance/coffee/UrlCachingTests.coffee

@@ -1,222 +1,222 @@
-# Client = require "./helpers/Client"
-# request = require "request"
-# require("chai").should()
-# sinon = require "sinon"
-# ClsiApp = require "./helpers/ClsiApp"
-
-# host = "localhost"
-
-# Server =
-# 	run: () ->
-# 		express = require "express"
-# 		app = express()
-
-# 		staticServer = express.static __dirname + "/../fixtures/"
-# 		app.get "/:random_id/*", (req, res, next) =>
-# 			@getFile(req.url)
-# 			req.url = "/" + req.params[0]
-# 			staticServer(req, res, next)
-
-# 		app.listen 31415, host
-
-# 	getFile: () ->
-
-# 	randomId: () ->
-# 		Math.random().toString(16).slice(2)
-
-# Server.run()
-
-# describe "Url Caching", ->
-# 	describe "Downloading an image for the first time", ->
-# 		before (done) ->
-# 			@project_id = Client.randomId()
-# 			@file = "#{Server.randomId()}/lion.png"
-# 			@request =
-# 				resources: [{
-# 					path: "main.tex"
-# 					content: '''
-# 						\\documentclass{article}
-# 						\\usepackage{graphicx}
-# 						\\begin{document}
-# 						\\includegraphics{lion.png}
-# 						\\end{document}
-# 					'''
-# 				}, {
-# 					path: "lion.png"
-# 					url: "http://#{host}:31415/#{@file}"
-# 				}]
-
-# 			sinon.spy Server, "getFile"
-# 			ClsiApp.ensureRunning =>
-# 				Client.compile @project_id, @request, (@error, @res, @body) => done()
-
-# 		afterEach ->
-# 			Server.getFile.restore()
-
-# 		it "should download the image", ->
-# 			Server.getFile
-# 				.calledWith("/" + @file)
-# 				.should.equal true
+Client = require "./helpers/Client"
+request = require "request"
+require("chai").should()
+sinon = require "sinon"
+ClsiApp = require "./helpers/ClsiApp"
+
+host = "localhost"
+
+Server =
+	run: () ->
+		express = require "express"
+		app = express()
+
+		staticServer = express.static __dirname + "/../fixtures/"
+		app.get "/:random_id/*", (req, res, next) =>
+			@getFile(req.url)
+			req.url = "/" + req.params[0]
+			staticServer(req, res, next)
+
+		app.listen 31415, host
+
+	getFile: () ->
+
+	randomId: () ->
+		Math.random().toString(16).slice(2)
+
+Server.run()
+
+describe "Url Caching", ->
+	describe "Downloading an image for the first time", ->
+		before (done) ->
+			@project_id = Client.randomId()
+			@file = "#{Server.randomId()}/lion.png"
+			@request =
+				resources: [{
+					path: "main.tex"
+					content: '''
+						\\documentclass{article}
+						\\usepackage{graphicx}
+						\\begin{document}
+						\\includegraphics{lion.png}
+						\\end{document}
+					'''
+				}, {
+					path: "lion.png"
+					url: "http://#{host}:31415/#{@file}"
+				}]
+
+			sinon.spy Server, "getFile"
+			ClsiApp.ensureRunning =>
+				Client.compile @project_id, @request, (@error, @res, @body) => done()
+
+		afterEach ->
+			Server.getFile.restore()
+
+		it "should download the image", ->
+			Server.getFile
+				.calledWith("/" + @file)
+				.should.equal true
 				
-# 	describe "When an image is in the cache and the last modified date is unchanged", ->
-# 		before (done) ->
-# 			@project_id = Client.randomId()
-# 			@file = "#{Server.randomId()}/lion.png"
-# 			@request =
-# 				resources: [{
-# 					path: "main.tex"
-# 					content: '''
-# 						\\documentclass{article}
-# 						\\usepackage{graphicx}
-# 						\\begin{document}
-# 						\\includegraphics{lion.png}
-# 						\\end{document}
-# 					'''
-# 				}, @image_resource = {
-# 					path: "lion.png"
-# 					url: "http://#{host}:31415/#{@file}"
-# 					modified: Date.now()
-# 				}]
-
-# 			Client.compile @project_id, @request, (@error, @res, @body) =>
-# 				sinon.spy Server, "getFile"
-# 				Client.compile @project_id, @request, (@error, @res, @body) =>
-# 					done()
-
-# 		after ->
-# 			Server.getFile.restore()
-
-# 		it "should not download the image again", ->
-# 			Server.getFile.called.should.equal false
-
-# 	describe "When an image is in the cache and the last modified date is advanced", ->
-# 		before (done) ->
-# 			@project_id = Client.randomId()
-# 			@file = "#{Server.randomId()}/lion.png"
-# 			@request =
-# 				resources: [{
-# 					path: "main.tex"
-# 					content: '''
-# 						\\documentclass{article}
-# 						\\usepackage{graphicx}
-# 						\\begin{document}
-# 						\\includegraphics{lion.png}
-# 						\\end{document}
-# 					'''
-# 				}, @image_resource = {
-# 					path: "lion.png"
-# 					url: "http://#{host}:31415/#{@file}"
-# 					modified: @last_modified = Date.now()
-# 				}]
-
-# 			Client.compile @project_id, @request, (@error, @res, @body) =>
-# 				sinon.spy Server, "getFile"
-# 				@image_resource.modified = new Date(@last_modified + 3000)
-# 				Client.compile @project_id, @request, (@error, @res, @body) =>
-# 					done()
-
-# 		afterEach ->
-# 			Server.getFile.restore()
-
-# 		it "should download the image again", ->
-# 			Server.getFile.called.should.equal true
-
-# 	describe "When an image is in the cache and the last modified date is further in the past", ->
-# 		before (done) ->
-# 			@project_id = Client.randomId()
-# 			@file = "#{Server.randomId()}/lion.png"
-# 			@request =
-# 				resources: [{
-# 					path: "main.tex"
-# 					content: '''
-# 						\\documentclass{article}
-# 						\\usepackage{graphicx}
-# 						\\begin{document}
-# 						\\includegraphics{lion.png}
-# 						\\end{document}
-# 					'''
-# 				}, @image_resource = {
-# 					path: "lion.png"
-# 					url: "http://#{host}:31415/#{@file}"
-# 					modified: @last_modified = Date.now()
-# 				}]
-
-# 			Client.compile @project_id, @request, (@error, @res, @body) =>
-# 				sinon.spy Server, "getFile"
-# 				@image_resource.modified = new Date(@last_modified - 3000)
-# 				Client.compile @project_id, @request, (@error, @res, @body) =>
-# 					done()
-
-# 		afterEach ->
-# 			Server.getFile.restore()
-
-# 		it "should not download the image again", ->
-# 			Server.getFile.called.should.equal false
-
-# 	describe "When an image is in the cache and the last modified date is not specified", ->
-# 		before (done) ->
-# 			@project_id = Client.randomId()
-# 			@file = "#{Server.randomId()}/lion.png"
-# 			@request =
-# 				resources: [{
-# 					path: "main.tex"
-# 					content: '''
-# 						\\documentclass{article}
-# 						\\usepackage{graphicx}
-# 						\\begin{document}
-# 						\\includegraphics{lion.png}
-# 						\\end{document}
-# 					'''
-# 				}, @image_resource = {
-# 					path: "lion.png"
-# 					url: "http://#{host}:31415/#{@file}"
-# 					modified: @last_modified = Date.now()
-# 				}]
-
-# 			Client.compile @project_id, @request, (@error, @res, @body) =>
-# 				sinon.spy Server, "getFile"
-# 				delete @image_resource.modified
-# 				Client.compile @project_id, @request, (@error, @res, @body) =>
-# 					done()
-
-# 		afterEach ->
-# 			Server.getFile.restore()
-
-# 		it "should download the image again", ->
-# 			Server.getFile.called.should.equal true
+	describe "When an image is in the cache and the last modified date is unchanged", ->
+		before (done) ->
+			@project_id = Client.randomId()
+			@file = "#{Server.randomId()}/lion.png"
+			@request =
+				resources: [{
+					path: "main.tex"
+					content: '''
+						\\documentclass{article}
+						\\usepackage{graphicx}
+						\\begin{document}
+						\\includegraphics{lion.png}
+						\\end{document}
+					'''
+				}, @image_resource = {
+					path: "lion.png"
+					url: "http://#{host}:31415/#{@file}"
+					modified: Date.now()
+				}]
+
+			Client.compile @project_id, @request, (@error, @res, @body) =>
+				sinon.spy Server, "getFile"
+				Client.compile @project_id, @request, (@error, @res, @body) =>
+					done()
+
+		after ->
+			Server.getFile.restore()
+
+		it "should not download the image again", ->
+			Server.getFile.called.should.equal false
+
+	describe "When an image is in the cache and the last modified date is advanced", ->
+		before (done) ->
+			@project_id = Client.randomId()
+			@file = "#{Server.randomId()}/lion.png"
+			@request =
+				resources: [{
+					path: "main.tex"
+					content: '''
+						\\documentclass{article}
+						\\usepackage{graphicx}
+						\\begin{document}
+						\\includegraphics{lion.png}
+						\\end{document}
+					'''
+				}, @image_resource = {
+					path: "lion.png"
+					url: "http://#{host}:31415/#{@file}"
+					modified: @last_modified = Date.now()
+				}]
+
+			Client.compile @project_id, @request, (@error, @res, @body) =>
+				sinon.spy Server, "getFile"
+				@image_resource.modified = new Date(@last_modified + 3000)
+				Client.compile @project_id, @request, (@error, @res, @body) =>
+					done()
+
+		afterEach ->
+			Server.getFile.restore()
+
+		it "should download the image again", ->
+			Server.getFile.called.should.equal true
+
+	describe "When an image is in the cache and the last modified date is further in the past", ->
+		before (done) ->
+			@project_id = Client.randomId()
+			@file = "#{Server.randomId()}/lion.png"
+			@request =
+				resources: [{
+					path: "main.tex"
+					content: '''
+						\\documentclass{article}
+						\\usepackage{graphicx}
+						\\begin{document}
+						\\includegraphics{lion.png}
+						\\end{document}
+					'''
+				}, @image_resource = {
+					path: "lion.png"
+					url: "http://#{host}:31415/#{@file}"
+					modified: @last_modified = Date.now()
+				}]
+
+			Client.compile @project_id, @request, (@error, @res, @body) =>
+				sinon.spy Server, "getFile"
+				@image_resource.modified = new Date(@last_modified - 3000)
+				Client.compile @project_id, @request, (@error, @res, @body) =>
+					done()
+
+		afterEach ->
+			Server.getFile.restore()
+
+		it "should not download the image again", ->
+			Server.getFile.called.should.equal false
+
+	describe "When an image is in the cache and the last modified date is not specified", ->
+		before (done) ->
+			@project_id = Client.randomId()
+			@file = "#{Server.randomId()}/lion.png"
+			@request =
+				resources: [{
+					path: "main.tex"
+					content: '''
+						\\documentclass{article}
+						\\usepackage{graphicx}
+						\\begin{document}
+						\\includegraphics{lion.png}
+						\\end{document}
+					'''
+				}, @image_resource = {
+					path: "lion.png"
+					url: "http://#{host}:31415/#{@file}"
+					modified: @last_modified = Date.now()
+				}]
+
+			Client.compile @project_id, @request, (@error, @res, @body) =>
+				sinon.spy Server, "getFile"
+				delete @image_resource.modified
+				Client.compile @project_id, @request, (@error, @res, @body) =>
+					done()
+
+		afterEach ->
+			Server.getFile.restore()
+
+		it "should download the image again", ->
+			Server.getFile.called.should.equal true
 		
-# 	describe "After clearing the cache", ->
-# 		before (done) ->
-# 			@project_id = Client.randomId()
-# 			@file = "#{Server.randomId()}/lion.png"
-# 			@request =
-# 				resources: [{
-# 					path: "main.tex"
-# 					content: '''
-# 						\\documentclass{article}
-# 						\\usepackage{graphicx}
-# 						\\begin{document}
-# 						\\includegraphics{lion.png}
-# 						\\end{document}
-# 					'''
-# 				}, @image_resource = {
-# 					path: "lion.png"
-# 					url: "http://#{host}:31415/#{@file}"
-# 					modified: @last_modified = Date.now()
-# 				}]
-
-# 			Client.compile @project_id, @request, (error) =>
-# 				throw error if error?
-# 				Client.clearCache @project_id, (error, res, body) =>
-# 					throw error if error?
-# 					sinon.spy Server, "getFile"
-# 					Client.compile @project_id, @request, (@error, @res, @body) =>
-# 						done()
-
-# 		afterEach ->
-# 			Server.getFile.restore()
-
-# 		it "should download the image again", ->
-# 			Server.getFile.called.should.equal true
+	describe "After clearing the cache", ->
+		before (done) ->
+			@project_id = Client.randomId()
+			@file = "#{Server.randomId()}/lion.png"
+			@request =
+				resources: [{
+					path: "main.tex"
+					content: '''
+						\\documentclass{article}
+						\\usepackage{graphicx}
+						\\begin{document}
+						\\includegraphics{lion.png}
+						\\end{document}
+					'''
+				}, @image_resource = {
+					path: "lion.png"
+					url: "http://#{host}:31415/#{@file}"
+					modified: @last_modified = Date.now()
+				}]
+
+			Client.compile @project_id, @request, (error) =>
+				throw error if error?
+				Client.clearCache @project_id, (error, res, body) =>
+					throw error if error?
+					sinon.spy Server, "getFile"
+					Client.compile @project_id, @request, (@error, @res, @body) =>
+						done()
+
+		afterEach ->
+			Server.getFile.restore()
+
+		it "should download the image again", ->
+			Server.getFile.called.should.equal true
 		
 				

+ 36 - 36
services/clsi/test/acceptance/coffee/WordcountTests.coffee

@@ -1,38 +1,38 @@
-# Client = require "./helpers/Client"
-# request = require "request"
-# require("chai").should()
-# expect = require("chai").expect
-# path = require("path")
-# fs = require("fs")
-# ClsiApp = require "./helpers/ClsiApp"
+Client = require "./helpers/Client"
+request = require "request"
+require("chai").should()
+expect = require("chai").expect
+path = require("path")
+fs = require("fs")
+ClsiApp = require "./helpers/ClsiApp"
 
-# describe "Syncing", ->
-# 	before (done) ->
-# 		@request =
-# 			resources: [
-# 				path: "main.tex"
-# 				content: fs.readFileSync(path.join(__dirname,"../fixtures/naugty_strings.txt"),"utf-8")
-# 			]
-# 		@project_id = Client.randomId()
-# 		ClsiApp.ensureRunning =>
-# 			Client.compile @project_id, @request, (@error, @res, @body) => done()
+describe "Syncing", ->
+	before (done) ->
+		@request =
+			resources: [
+				path: "main.tex"
+				content: fs.readFileSync(path.join(__dirname,"../fixtures/naugty_strings.txt"),"utf-8")
+			]
+		@project_id = Client.randomId()
+		ClsiApp.ensureRunning =>
+			Client.compile @project_id, @request, (@error, @res, @body) => done()
 
-# 	describe "wordcount file", ->
-# 		it "should return wordcount info", (done) ->
-# 			Client.wordcount @project_id, "main.tex", (error, result) ->
-# 				throw error if error?
-# 				expect(result).to.deep.equal(
-# 					texcount: { 
-# 						encode: "utf8"
-# 						textWords: 2281
-# 						headWords: 2
-# 						outside: 0
-# 						headers: 2
-# 						elements: 0
-# 						mathInline: 6
-# 						mathDisplay: 0
-# 						errors: 0
-# 						messages: ""
-# 					}
-# 				)
-# 				done()
+	describe "wordcount file", ->
+		it "should return wordcount info", (done) ->
+			Client.wordcount @project_id, "main.tex", (error, result) ->
+				throw error if error?
+				expect(result).to.deep.equal(
+					texcount: { 
+						encode: "utf8"
+						textWords: 2281
+						headWords: 2
+						outside: 0
+						headers: 2
+						elements: 0
+						mathInline: 6
+						mathDisplay: 0
+						errors: 0
+						messages: ""
+					}
+				)
+				done()