mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
uncomment tests
This commit is contained in:
parent
f9b6b3dda8
commit
2168f20715
2 changed files with 225 additions and 225 deletions
|
@ -1,222 +1,222 @@
|
|||
# Client = require "./helpers/Client"
|
||||
# request = require "request"
|
||||
# require("chai").should()
|
||||
# sinon = require "sinon"
|
||||
# ClsiApp = require "./helpers/ClsiApp"
|
||||
Client = require "./helpers/Client"
|
||||
request = require "request"
|
||||
require("chai").should()
|
||||
sinon = require "sinon"
|
||||
ClsiApp = require "./helpers/ClsiApp"
|
||||
|
||||
# host = "localhost"
|
||||
host = "localhost"
|
||||
|
||||
# Server =
|
||||
# run: () ->
|
||||
# express = require "express"
|
||||
# app = express()
|
||||
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)
|
||||
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
|
||||
app.listen 31415, host
|
||||
|
||||
# getFile: () ->
|
||||
getFile: () ->
|
||||
|
||||
# randomId: () ->
|
||||
# Math.random().toString(16).slice(2)
|
||||
randomId: () ->
|
||||
Math.random().toString(16).slice(2)
|
||||
|
||||
# Server.run()
|
||||
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}"
|
||||
# }]
|
||||
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()
|
||||
sinon.spy Server, "getFile"
|
||||
ClsiApp.ensureRunning =>
|
||||
Client.compile @project_id, @request, (@error, @res, @body) => done()
|
||||
|
||||
# afterEach ->
|
||||
# Server.getFile.restore()
|
||||
afterEach ->
|
||||
Server.getFile.restore()
|
||||
|
||||
# it "should download the image", ->
|
||||
# Server.getFile
|
||||
# .calledWith("/" + @file)
|
||||
# .should.equal true
|
||||
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()
|
||||
# }]
|
||||
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()
|
||||
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()
|
||||
after ->
|
||||
Server.getFile.restore()
|
||||
|
||||
# it "should not download the image again", ->
|
||||
# Server.getFile.called.should.equal false
|
||||
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()
|
||||
# }]
|
||||
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()
|
||||
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()
|
||||
afterEach ->
|
||||
Server.getFile.restore()
|
||||
|
||||
# it "should download the image again", ->
|
||||
# Server.getFile.called.should.equal true
|
||||
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()
|
||||
# }]
|
||||
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()
|
||||
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()
|
||||
afterEach ->
|
||||
Server.getFile.restore()
|
||||
|
||||
# it "should not download the image again", ->
|
||||
# Server.getFile.called.should.equal false
|
||||
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()
|
||||
# }]
|
||||
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()
|
||||
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()
|
||||
afterEach ->
|
||||
Server.getFile.restore()
|
||||
|
||||
# it "should download the image again", ->
|
||||
# Server.getFile.called.should.equal true
|
||||
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()
|
||||
# }]
|
||||
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()
|
||||
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()
|
||||
afterEach ->
|
||||
Server.getFile.restore()
|
||||
|
||||
# it "should download the image again", ->
|
||||
# Server.getFile.called.should.equal true
|
||||
it "should download the image again", ->
|
||||
Server.getFile.called.should.equal true
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue