balena-cli/lib/models/_canvas.spec.coffee

41 lines
743 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)
mock = require('../../tests/utils/mock')
2014-11-18 15:14:33 +00:00
canvas = require('./_canvas')
config = require('../config')
URI =
application: url.resolve(config.apiPrefix, 'application')
RESPONSE =
applications:
d: [
{ id: 1 }
{ id: 2 }
]
describe 'Canvas:', ->
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)