2014-11-18 15:14:33 +00:00
|
|
|
nock = require('nock')
|
|
|
|
url = require('url')
|
|
|
|
|
|
|
|
chai = require('chai')
|
|
|
|
chaiAsPromised = require('chai-as-promised')
|
|
|
|
expect = chai.expect
|
|
|
|
chai.use(chaiAsPromised)
|
|
|
|
|
2014-11-26 16:56:52 +00:00
|
|
|
data = require('../data/data')
|
2014-11-26 16:15:40 +00:00
|
|
|
mock = require('../../../tests/utils/mock')
|
2014-11-18 15:14:33 +00:00
|
|
|
canvas = require('./_canvas')
|
2014-11-26 17:42:05 +00:00
|
|
|
config = require('../config')
|
2014-11-18 15:14:33 +00:00
|
|
|
|
|
|
|
URI =
|
|
|
|
application: url.resolve(config.apiPrefix, 'application')
|
|
|
|
|
|
|
|
RESPONSE =
|
|
|
|
applications:
|
|
|
|
d: [
|
|
|
|
{ id: 1 }
|
|
|
|
{ id: 2 }
|
|
|
|
]
|
|
|
|
|
|
|
|
describe 'Canvas:', ->
|
|
|
|
|
2014-11-26 16:56:52 +00:00
|
|
|
beforeEach (done) ->
|
|
|
|
mock.fs.init()
|
|
|
|
data.prefix.set(config.dataPrefix, done)
|
|
|
|
|
|
|
|
afterEach ->
|
|
|
|
mock.fs.restore()
|
|
|
|
|
2014-11-24 18:55:05 +00:00
|
|
|
before ->
|
|
|
|
mock.connection.init()
|
|
|
|
|
|
|
|
after ->
|
|
|
|
mock.connection.restore()
|
|
|
|
|
2014-11-18 15:14:33 +00:00
|
|
|
beforeEach ->
|
|
|
|
nock(config.remoteUrl)
|
|
|
|
.get(URI.application)
|
|
|
|
.reply(200, RESPONSE.applications)
|
|
|
|
|
|
|
|
it 'should construct the correct url', ->
|
|
|
|
promise = canvas.get
|
|
|
|
resource: 'application'
|
|
|
|
|
|
|
|
expect(promise).to.become(RESPONSE.applications.d)
|