|
@@ -1,13 +1,3 @@
|
|
|
-/* eslint-disable
|
|
|
|
|
- no-return-assign,
|
|
|
|
|
-*/
|
|
|
|
|
-// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
|
-// Fix any style issues and re-enable lint.
|
|
|
|
|
-/*
|
|
|
|
|
- * decaffeinate suggestions:
|
|
|
|
|
- * DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
|
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
|
- */
|
|
|
|
|
const SandboxedModule = require('sandboxed-module')
|
|
const SandboxedModule = require('sandboxed-module')
|
|
|
const sinon = require('sinon')
|
|
const sinon = require('sinon')
|
|
|
const { expect } = require('chai')
|
|
const { expect } = require('chai')
|
|
@@ -37,23 +27,23 @@ describe('RequestParser', function () {
|
|
|
resources: [],
|
|
resources: [],
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
- return (this.RequestParser = SandboxedModule.require(modulePath, {
|
|
|
|
|
|
|
+ this.RequestParser = SandboxedModule.require(modulePath, {
|
|
|
requires: {
|
|
requires: {
|
|
|
'@overleaf/settings': (this.settings = {}),
|
|
'@overleaf/settings': (this.settings = {}),
|
|
|
},
|
|
},
|
|
|
- }))
|
|
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
afterEach(function () {
|
|
|
- return tk.reset()
|
|
|
|
|
|
|
+ tk.reset()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('without a top level object', function () {
|
|
describe('without a top level object', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
- return this.RequestParser.parse([], this.callback)
|
|
|
|
|
|
|
+ this.RequestParser.parse([], this.callback)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
expect(this.callback).to.have.been.called
|
|
expect(this.callback).to.have.been.called
|
|
|
expect(this.callback.args[0][0].message).to.equal(
|
|
expect(this.callback.args[0][0].message).to.equal(
|
|
|
'top level object should have a compile attribute'
|
|
'top level object should have a compile attribute'
|
|
@@ -63,10 +53,10 @@ describe('RequestParser', function () {
|
|
|
|
|
|
|
|
describe('without a compile attribute', function () {
|
|
describe('without a compile attribute', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
- return this.RequestParser.parse({}, this.callback)
|
|
|
|
|
|
|
+ this.RequestParser.parse({}, this.callback)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
expect(this.callback).to.have.been.called
|
|
expect(this.callback).to.have.been.called
|
|
|
expect(this.callback.args[0][0].message).to.equal(
|
|
expect(this.callback.args[0][0].message).to.equal(
|
|
|
'top level object should have a compile attribute'
|
|
'top level object should have a compile attribute'
|
|
@@ -77,14 +67,15 @@ describe('RequestParser', function () {
|
|
|
describe('without a valid compiler', function () {
|
|
describe('without a valid compiler', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.validRequest.compile.options.compiler = 'not-a-compiler'
|
|
this.validRequest.compile.options.compiler = 'not-a-compiler'
|
|
|
- return this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
- return this.callback
|
|
|
|
|
- .calledWith(
|
|
|
|
|
- 'compiler attribute should be one of: pdflatex, latex, xelatex, lualatex'
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
|
|
+ this.callback
|
|
|
|
|
+ .calledWithMatch({
|
|
|
|
|
+ message:
|
|
|
|
|
+ 'compiler attribute should be one of: pdflatex, latex, xelatex, lualatex',
|
|
|
|
|
+ })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -92,29 +83,29 @@ describe('RequestParser', function () {
|
|
|
describe('without a compiler specified', function () {
|
|
describe('without a compiler specified', function () {
|
|
|
beforeEach(function (done) {
|
|
beforeEach(function (done) {
|
|
|
delete this.validRequest.compile.options.compiler
|
|
delete this.validRequest.compile.options.compiler
|
|
|
- return this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
if (error) return done(error)
|
|
if (error) return done(error)
|
|
|
this.data = data
|
|
this.data = data
|
|
|
done()
|
|
done()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should set the compiler to pdflatex by default', function () {
|
|
|
|
|
- return this.data.compiler.should.equal('pdflatex')
|
|
|
|
|
|
|
+ it('should set the compiler to pdflatex by default', function () {
|
|
|
|
|
+ this.data.compiler.should.equal('pdflatex')
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('with imageName set', function () {
|
|
describe('with imageName set', function () {
|
|
|
beforeEach(function (done) {
|
|
beforeEach(function (done) {
|
|
|
- return this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
if (error) return done(error)
|
|
if (error) return done(error)
|
|
|
this.data = data
|
|
this.data = data
|
|
|
done()
|
|
done()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should set the imageName', function () {
|
|
|
|
|
- return this.data.imageName.should.equal('basicImageName/here:2017-1')
|
|
|
|
|
|
|
+ it('should set the imageName', function () {
|
|
|
|
|
+ this.data.imageName.should.equal('basicImageName/here:2017-1')
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -163,46 +154,44 @@ describe('RequestParser', function () {
|
|
|
describe('with flags set', function () {
|
|
describe('with flags set', function () {
|
|
|
beforeEach(function (done) {
|
|
beforeEach(function (done) {
|
|
|
this.validRequest.compile.options.flags = ['-file-line-error']
|
|
this.validRequest.compile.options.flags = ['-file-line-error']
|
|
|
- return this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
if (error) return done(error)
|
|
if (error) return done(error)
|
|
|
this.data = data
|
|
this.data = data
|
|
|
done()
|
|
done()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should set the flags attribute', function () {
|
|
|
|
|
- return expect(this.data.flags).to.deep.equal(['-file-line-error'])
|
|
|
|
|
|
|
+ it('should set the flags attribute', function () {
|
|
|
|
|
+ expect(this.data.flags).to.deep.equal(['-file-line-error'])
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('with flags not specified', function () {
|
|
describe('with flags not specified', function () {
|
|
|
beforeEach(function (done) {
|
|
beforeEach(function (done) {
|
|
|
- return this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
if (error) return done(error)
|
|
if (error) return done(error)
|
|
|
this.data = data
|
|
this.data = data
|
|
|
done()
|
|
done()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('it should have an empty flags list', function () {
|
|
|
|
|
- return expect(this.data.flags).to.deep.equal([])
|
|
|
|
|
|
|
+ it('it should have an empty flags list', function () {
|
|
|
|
|
+ expect(this.data.flags).to.deep.equal([])
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('without a timeout specified', function () {
|
|
describe('without a timeout specified', function () {
|
|
|
beforeEach(function (done) {
|
|
beforeEach(function (done) {
|
|
|
delete this.validRequest.compile.options.timeout
|
|
delete this.validRequest.compile.options.timeout
|
|
|
- return this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
if (error) return done(error)
|
|
if (error) return done(error)
|
|
|
this.data = data
|
|
this.data = data
|
|
|
done()
|
|
done()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should set the timeout to MAX_TIMEOUT', function () {
|
|
|
|
|
- return this.data.timeout.should.equal(
|
|
|
|
|
- this.RequestParser.MAX_TIMEOUT * 1000
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ it('should set the timeout to MAX_TIMEOUT', function () {
|
|
|
|
|
+ this.data.timeout.should.equal(this.RequestParser.MAX_TIMEOUT * 1000)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -210,31 +199,29 @@ describe('RequestParser', function () {
|
|
|
beforeEach(function (done) {
|
|
beforeEach(function (done) {
|
|
|
this.validRequest.compile.options.timeout =
|
|
this.validRequest.compile.options.timeout =
|
|
|
this.RequestParser.MAX_TIMEOUT + 1
|
|
this.RequestParser.MAX_TIMEOUT + 1
|
|
|
- return this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
if (error) return done(error)
|
|
if (error) return done(error)
|
|
|
this.data = data
|
|
this.data = data
|
|
|
done()
|
|
done()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should set the timeout to MAX_TIMEOUT', function () {
|
|
|
|
|
- return this.data.timeout.should.equal(
|
|
|
|
|
- this.RequestParser.MAX_TIMEOUT * 1000
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ it('should set the timeout to MAX_TIMEOUT', function () {
|
|
|
|
|
+ this.data.timeout.should.equal(this.RequestParser.MAX_TIMEOUT * 1000)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('with a timeout', function () {
|
|
describe('with a timeout', function () {
|
|
|
beforeEach(function (done) {
|
|
beforeEach(function (done) {
|
|
|
- return this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, (error, data) => {
|
|
|
if (error) return done(error)
|
|
if (error) return done(error)
|
|
|
this.data = data
|
|
this.data = data
|
|
|
done()
|
|
done()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should set the timeout (in milliseconds)', function () {
|
|
|
|
|
- return this.data.timeout.should.equal(
|
|
|
|
|
|
|
+ it('should set the timeout (in milliseconds)', function () {
|
|
|
|
|
+ this.data.timeout.should.equal(
|
|
|
this.validRequest.compile.options.timeout * 1000
|
|
this.validRequest.compile.options.timeout * 1000
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
@@ -244,12 +231,14 @@ describe('RequestParser', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
delete this.validResource.path
|
|
delete this.validResource.path
|
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
|
- return this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
- return this.callback
|
|
|
|
|
- .calledWith('all resources should have a path attribute')
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
|
|
+ this.callback
|
|
|
|
|
+ .calledWithMatch({
|
|
|
|
|
+ message: 'all resources should have a path attribute',
|
|
|
|
|
+ })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -259,11 +248,11 @@ describe('RequestParser', function () {
|
|
|
this.validResource.path = this.path = 'test.tex'
|
|
this.validResource.path = this.path = 'test.tex'
|
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
- return (this.data = this.callback.args[0][1])
|
|
|
|
|
|
|
+ this.data = this.callback.args[0][1]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return the path in the parsed response', function () {
|
|
|
|
|
- return this.data.resources[0].path.should.equal(this.path)
|
|
|
|
|
|
|
+ it('should return the path in the parsed response', function () {
|
|
|
|
|
+ this.data.resources[0].path.should.equal(this.path)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -271,15 +260,16 @@ describe('RequestParser', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.validResource.modified = 'not-a-date'
|
|
this.validResource.modified = 'not-a-date'
|
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
|
- return this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
- return this.callback
|
|
|
|
|
- .calledWith(
|
|
|
|
|
- 'resource modified date could not be understood: ' +
|
|
|
|
|
- this.validResource.modified
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
|
|
+ this.callback
|
|
|
|
|
+ .calledWithMatch({
|
|
|
|
|
+ message:
|
|
|
|
|
+ 'resource modified date could not be understood: ' +
|
|
|
|
|
+ this.validResource.modified,
|
|
|
|
|
+ })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -290,12 +280,12 @@ describe('RequestParser', function () {
|
|
|
this.validResource.modified = this.date
|
|
this.validResource.modified = this.date
|
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
- return (this.data = this.callback.args[0][1])
|
|
|
|
|
|
|
+ this.data = this.callback.args[0][1]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return the date as a Javascript Date object', function () {
|
|
|
|
|
|
|
+ it('should return the date as a Javascript Date object', function () {
|
|
|
;(this.data.resources[0].modified instanceof Date).should.equal(true)
|
|
;(this.data.resources[0].modified instanceof Date).should.equal(true)
|
|
|
- return this.data.resources[0].modified
|
|
|
|
|
|
|
+ this.data.resources[0].modified
|
|
|
.getTime()
|
|
.getTime()
|
|
|
.should.equal(Date.parse(this.date))
|
|
.should.equal(Date.parse(this.date))
|
|
|
})
|
|
})
|
|
@@ -306,14 +296,15 @@ describe('RequestParser', function () {
|
|
|
delete this.validResource.url
|
|
delete this.validResource.url
|
|
|
delete this.validResource.content
|
|
delete this.validResource.content
|
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
|
- return this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
- return this.callback
|
|
|
|
|
- .calledWith(
|
|
|
|
|
- 'all resources should have either a url or content attribute'
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
|
|
+ this.callback
|
|
|
|
|
+ .calledWithMatch({
|
|
|
|
|
+ message:
|
|
|
|
|
+ 'all resources should have either a url or content attribute',
|
|
|
|
|
+ })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -322,12 +313,12 @@ describe('RequestParser', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.validResource.content = []
|
|
this.validResource.content = []
|
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
|
- return this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
- return this.callback
|
|
|
|
|
- .calledWith('content attribute should be a string')
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
|
|
+ this.callback
|
|
|
|
|
+ .calledWithMatch({ message: 'content attribute should be a string' })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -336,12 +327,12 @@ describe('RequestParser', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.validResource.url = []
|
|
this.validResource.url = []
|
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
|
- return this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
- return this.callback
|
|
|
|
|
- .calledWith('url attribute should be a string')
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
|
|
+ this.callback
|
|
|
|
|
+ .calledWithMatch({ message: 'url attribute should be a string' })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -351,11 +342,11 @@ describe('RequestParser', function () {
|
|
|
this.validResource.url = this.url = 'www.example.com'
|
|
this.validResource.url = this.url = 'www.example.com'
|
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
- return (this.data = this.callback.args[0][1])
|
|
|
|
|
|
|
+ this.data = this.callback.args[0][1]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return the url in the parsed response', function () {
|
|
|
|
|
- return this.data.resources[0].url.should.equal(this.url)
|
|
|
|
|
|
|
+ it('should return the url in the parsed response', function () {
|
|
|
|
|
+ this.data.resources[0].url.should.equal(this.url)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -364,11 +355,11 @@ describe('RequestParser', function () {
|
|
|
this.validResource.content = this.content = 'Hello world'
|
|
this.validResource.content = this.content = 'Hello world'
|
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
this.validRequest.compile.resources.push(this.validResource)
|
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
- return (this.data = this.callback.args[0][1])
|
|
|
|
|
|
|
+ this.data = this.callback.args[0][1]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return the content in the parsed response', function () {
|
|
|
|
|
- return this.data.resources[0].content.should.equal(this.content)
|
|
|
|
|
|
|
+ it('should return the content in the parsed response', function () {
|
|
|
|
|
+ this.data.resources[0].content.should.equal(this.content)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -376,11 +367,11 @@ describe('RequestParser', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
delete this.validRequest.compile.rootResourcePath
|
|
delete this.validRequest.compile.rootResourcePath
|
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
- return (this.data = this.callback.args[0][1])
|
|
|
|
|
|
|
+ this.data = this.callback.args[0][1]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it("should set the root resource path to 'main.tex' by default", function () {
|
|
|
|
|
- return this.data.rootResourcePath.should.equal('main.tex')
|
|
|
|
|
|
|
+ it("should set the root resource path to 'main.tex' by default", function () {
|
|
|
|
|
+ this.data.rootResourcePath.should.equal('main.tex')
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -388,23 +379,25 @@ describe('RequestParser', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.validRequest.compile.rootResourcePath = this.path = 'test.tex'
|
|
this.validRequest.compile.rootResourcePath = this.path = 'test.tex'
|
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
- return (this.data = this.callback.args[0][1])
|
|
|
|
|
|
|
+ this.data = this.callback.args[0][1]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return the root resource path in the parsed response', function () {
|
|
|
|
|
- return this.data.rootResourcePath.should.equal(this.path)
|
|
|
|
|
|
|
+ it('should return the root resource path in the parsed response', function () {
|
|
|
|
|
+ this.data.rootResourcePath.should.equal(this.path)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('with a root resource path that is not a string', function () {
|
|
describe('with a root resource path that is not a string', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.validRequest.compile.rootResourcePath = []
|
|
this.validRequest.compile.rootResourcePath = []
|
|
|
- return this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
|
|
|
|
+ this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
- return this.callback
|
|
|
|
|
- .calledWith('rootResourcePath attribute should be a string')
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
|
|
+ this.callback
|
|
|
|
|
+ .calledWithMatch({
|
|
|
|
|
+ message: 'rootResourcePath attribute should be a string',
|
|
|
|
|
+ })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -420,15 +413,15 @@ describe('RequestParser', function () {
|
|
|
content: 'Hello world',
|
|
content: 'Hello world',
|
|
|
})
|
|
})
|
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
- return (this.data = this.callback.args[0][1])
|
|
|
|
|
|
|
+ this.data = this.callback.args[0][1]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return the escaped resource', function () {
|
|
it('should return the escaped resource', function () {
|
|
|
- return this.data.rootResourcePath.should.equal(this.goodPath)
|
|
|
|
|
|
|
+ this.data.rootResourcePath.should.equal(this.goodPath)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should also escape the resource path', function () {
|
|
|
|
|
- return this.data.resources[0].path.should.equal(this.goodPath)
|
|
|
|
|
|
|
+ it('should also escape the resource path', function () {
|
|
|
|
|
+ this.data.resources[0].path.should.equal(this.goodPath)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -436,12 +429,12 @@ describe('RequestParser', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.validRequest.compile.rootResourcePath = 'foo/../../bar.tex'
|
|
this.validRequest.compile.rootResourcePath = 'foo/../../bar.tex'
|
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
- return (this.data = this.callback.args[0][1])
|
|
|
|
|
|
|
+ this.data = this.callback.args[0][1]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
- return this.callback
|
|
|
|
|
- .calledWith('relative path in root resource')
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
|
|
+ this.callback
|
|
|
|
|
+ .calledWithMatch({ message: 'relative path in root resource' })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -450,26 +443,28 @@ describe('RequestParser', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.validRequest.compile.rootResourcePath = 'foo/#../bar.tex'
|
|
this.validRequest.compile.rootResourcePath = 'foo/#../bar.tex'
|
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
- return (this.data = this.callback.args[0][1])
|
|
|
|
|
|
|
+ this.data = this.callback.args[0][1]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
- return this.callback
|
|
|
|
|
- .calledWith('relative path in root resource')
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
|
|
+ this.callback
|
|
|
|
|
+ .calledWithMatch({ message: 'relative path in root resource' })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('with an unknown syncType', function () {
|
|
|
|
|
|
|
+ describe('with an unknown syncType', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.validRequest.compile.options.syncType = 'unexpected'
|
|
this.validRequest.compile.options.syncType = 'unexpected'
|
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
this.RequestParser.parse(this.validRequest, this.callback)
|
|
|
- return (this.data = this.callback.args[0][1])
|
|
|
|
|
|
|
+ this.data = this.callback.args[0][1]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an error', function () {
|
|
|
|
|
- return this.callback
|
|
|
|
|
- .calledWith('syncType attribute should be one of: full, incremental')
|
|
|
|
|
|
|
+ it('should return an error', function () {
|
|
|
|
|
+ this.callback
|
|
|
|
|
+ .calledWithMatch({
|
|
|
|
|
+ message: 'syncType attribute should be one of: full, incremental',
|
|
|
|
|
+ })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|