node-ciscospark
Version:
Super-Simple Lightweight Javascript wrapper for Cisco Spark API
90 lines (78 loc) • 2.83 kB
JavaScript
;
/* eslint-env mocha */
/* eslint-disable no-unused-expressions */
var Spark = require('../src');
var expect = require('chai').expect;
var TEST_ACCESSTOKEN = '**TestAccessToken**';
var TEST_USERAGENT = '**TestUsergent**';
var TEST_TEAM_ID = '**TestTeamId**';
/** @test {Teams} */
describe('CiscoSpark.teams', function () {
before(function () {
this.spark = new Spark(TEST_ACCESSTOKEN, TEST_USERAGENT);
this.spark.requestCallback = function (options, callback) {
return callback(null, {
options: options,
timestamp: Date.now()
});
};
this.instance = this.spark.teams;
});
/** @test {Teams#list} */
it('should list Teams', function (done) {
var _this = this;
var max = 99;
this.instance.list({ max: max }, function (err, response) {
expect(err).to.be.not.ok;
expect(response.options.headers.Authorization).to.be.equal('Bearer ' + TEST_ACCESSTOKEN);
expect(response.options.headers['User-Agent']).to.be.equal(TEST_USERAGENT);
expect(response.options.url).to.be.equal(_this.instance.apiUrl);
expect(response.options.method).to.be.equal('GET');
expect(response.options.qs.max).to.be.equal(max);
done();
});
});
/** @test {Teams#create} */
it('should create a Team', function (done) {
var name = 'Test Team';
this.instance.create({
name: name
}, function (err, response) {
expect(err).to.be.not.ok;
expect(response.options.method).to.be.equal('POST');
expect(response.options.form.name).to.be.equal(name);
done();
});
});
/** @test {Teams#get} */
it('should get Team Details', function (done) {
var _this2 = this;
this.instance.get(TEST_TEAM_ID, function (err, response) {
expect(err).to.be.not.ok;
expect(response.options.url).to.be.equal(_this2.instance.apiUrl + '/' + TEST_TEAM_ID);
expect(response.options.method).to.be.equal('GET');
done();
});
});
/** @test {Teams#update} */
it('should update Team Details', function (done) {
var _this3 = this;
this.instance.update(TEST_TEAM_ID, { name: 'new name' }, function (err, response) {
expect(err).to.be.not.ok;
expect(response.options.url).to.be.equal(_this3.instance.apiUrl + '/' + TEST_TEAM_ID);
expect(response.options.json.name).to.be.ok;
expect(response.options.method).to.be.equal('PUT');
done();
});
});
/** @test {Teams#delete} */
it('should delete a Team Membership', function (done) {
var _this4 = this;
this.instance.delete(TEST_TEAM_ID, function (err, response) {
expect(err).to.be.not.ok;
expect(response.options.url).to.be.equal(_this4.instance.apiUrl + '/' + TEST_TEAM_ID);
expect(response.options.method).to.be.equal('DELETE');
done();
});
});
});