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-12-09 18:53:57 +00:00
|
|
|
pine = require('./_pine')
|
2014-12-03 16:03:54 +00:00
|
|
|
settings = require('../settings')
|
2014-11-18 15:14:33 +00:00
|
|
|
|
2014-12-09 18:53:57 +00:00
|
|
|
describe 'Pine:', ->
|
2014-11-18 15:14:33 +00:00
|
|
|
|
2014-12-05 16:52:31 +00:00
|
|
|
URI =
|
|
|
|
application: url.resolve(settings.get('apiPrefix'), 'application')
|
2014-11-18 15:14:33 +00:00
|
|
|
|
2014-12-05 16:52:31 +00:00
|
|
|
RESPONSE =
|
|
|
|
applications:
|
|
|
|
d: [
|
|
|
|
{ id: 1 }
|
|
|
|
{ id: 2 }
|
|
|
|
]
|
2014-11-18 15:14:33 +00:00
|
|
|
|
2014-11-26 16:56:52 +00:00
|
|
|
beforeEach (done) ->
|
|
|
|
mock.fs.init()
|
2014-12-05 16:52:31 +00:00
|
|
|
|
|
|
|
nock(settings.get('remoteUrl'))
|
|
|
|
.get(URI.application)
|
|
|
|
.reply(200, RESPONSE.applications)
|
|
|
|
|
2014-12-05 14:53:59 +00:00
|
|
|
data.prefix.set(settings.get('dataPrefix'), done)
|
2014-11-26 16:56:52 +00:00
|
|
|
|
|
|
|
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
|
|
|
it 'should construct the correct url', ->
|
2014-12-09 18:53:57 +00:00
|
|
|
promise = pine.get
|
2014-11-18 15:14:33 +00:00
|
|
|
resource: 'application'
|
|
|
|
|
|
|
|
expect(promise).to.become(RESPONSE.applications.d)
|