balena-cli/lib/resin/models/_pine.spec.coffee

49 lines
912 B
CoffeeScript
Raw Normal View History

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')
pine = require('./_pine')
settings = require('../settings')
2014-11-18 15:14:33 +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()
before ->
mock.connection.init()
after ->
mock.connection.restore()
2014-11-18 15:14:33 +00:00
it 'should construct the correct url', ->
promise = pine.get
2014-11-18 15:14:33 +00:00
resource: 'application'
expect(promise).to.become(RESPONSE.applications.d)