Commit 53b6059f authored by Patricio Bruna's avatar Patricio Bruna

Muchos cambios. De ahora en adelante mas prolijo los commits

parent 33cabdb0
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -10,7 +10,7 @@ var http = require("http"), ...@@ -10,7 +10,7 @@ var http = require("http"),
http.createServer(function(request, response) { http.createServer(function(request, response) {
console.log(request); console.log(request.url);
if (request.url.indexOf(prefix) === 0) { if (request.url.indexOf(prefix) === 0) {
proxy.web(request, response, { target: 'https://127.0.0.1:7071', secure: false }); proxy.web(request, response, { target: 'https://127.0.0.1:7071', secure: false });
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
var jszimbra = require('js-zimbra'); var jszimbra = require('js-zimbra');
import Dictionary from './utils/dictionary.js';
class Error { class Error {
constructor(err) { constructor(err) {
...@@ -30,6 +31,8 @@ class ZimbraAdminApi { ...@@ -30,6 +31,8 @@ class ZimbraAdminApi {
this.password = auth_object.password; this.password = auth_object.password;
this._client = new jszimbra.Communication({url: auth_object.url}); this._client = new jszimbra.Communication({url: auth_object.url});
this.default_params = { namespace: 'zimbraAdmin', params: { } }; this.default_params = { namespace: 'zimbraAdmin', params: { } };
this.parseAllResponse = this.parseAllResponse.bind(this);
this.dictionary = new Dictionary();
} }
...@@ -78,7 +81,7 @@ class ZimbraAdminApi { ...@@ -78,7 +81,7 @@ class ZimbraAdminApi {
return request; return request;
} }
makeRequest(request, resource, parse_response, success, error) { makeRequest(request, resource, parse_response, callback) {
let that = this; let that = this;
this.default_params.name = `${request}Request`; this.default_params.name = `${request}Request`;
let request_object = that.buildRequest(); let request_object = that.buildRequest();
...@@ -87,11 +90,12 @@ class ZimbraAdminApi { ...@@ -87,11 +90,12 @@ class ZimbraAdminApi {
return that.handleError(err); return that.handleError(err);
} }
let obj = new Object(self); let obj = new Object(self);
obj.success = success;
obj.error = error;
obj.response_name = `${request}Response`; obj.response_name = `${request}Response`;
obj.param_object_name = resource.toLocaleLowerCase(); obj.param_object_name = resource.toLocaleLowerCase();
that.client.send(request_object, parse_response.bind(obj)); that.client.send(request_object, function(err, data){
if (err) return callback(err);
parse_response(data, obj, callback);
});
}); });
} }
...@@ -104,33 +108,43 @@ class ZimbraAdminApi { ...@@ -104,33 +108,43 @@ class ZimbraAdminApi {
return this.success(response_object); return this.success(response_object);
} }
parseAllResponse(err, data){
if (err) { parseAllResponse(data, obj, callback){
return this.error(err); const resource = obj.param_object_name.toLowerCase();
} const that = this;
let response_object = data.get()[this.response_name][this.param_object_name]; const response_name = that.dictionary.resourceResponseName(resource)
return this.success(response_object); const response_object = data.get()[obj.response_name][response_name];
const response_array = [];
response_object.forEach((r) => {
let element = that.dictionary.classFactory(resource, r);
response_array.push(element);
});
return callback(null, response_array);
} }
getAll(resource, success, error) { getAll(resource, callback) {
if (this.client.token) { if (this.client.token) {
this.makeRequest(`GetAll${resource}s`, resource, this.parseAllResponse, success, error); this.makeRequest(`GetAll${resource}s`, resource, this.parseAllResponse, callback);
} else { } else {
var that = this; var that = this;
let callback = function(err, response){ let getAllCallback = function(err, response){
if (err) return this.handleError(err); if (err) return this.handleError(err);
that.makeRequest(`GetAll${resource}s`, resource, that.parseAllResponse, success, error); that.makeRequest(`GetAll${resource}s`, resource, that.parseAllResponse, callback);
} }
this.login(callback); this.login(getAllCallback);
} }
} }
getAllDomains(success, error) { getAllDomains(callback) {
this.getAll('Domain', success, error); this.getAll('Domain', callback);
}
getAllAccounts(callback) {
this.getAll('Account', callback);
} }
getAllAccounts(success, error) { getAllDistributionLists(callback) {
this.getAll('Account', success, error); this.getAll('DistributionList', callback);
} }
} }
......
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
import $ from 'jquery';
import jszimbra from 'js-zimbra';
import Domain from '../zimbra/domain.jsx';
import Account from '../zimbra/account.jsx';
let domain;
let account;
// función que maneja el error como corresponde
function handleError(methodName, err) {
var e = null;
try {
e = JSON.parse(err);
} catch (parseError) {
e = null;
}
console.error(methodName, e); //eslint-disable-line no-console
// Aqui deberiamos revisar si falta hacer login nuevamente
return e;
}
function error(err) {
console.error(err);
}
function success(data) {
console.log("SUCCESS");
return data;
}
export function getClientConfig(success, error) {
return $.ajax({
url: 'config/config.json',
dataType: 'json',
success,
error: function onError(xhr, status, err) {
var e = handleError('getClientConfig', err);
error(e);
}
});
}
export function login(username, secret, success, error) {
const zimbra = new jszimbra.Communication({
url: global.window.manager_config.zimbraUrl
});
zimbra.auth({
username,
secret,
isPassword: true,
isAdmin: true
}, (err) => {
if (err) {
var e = handleError('login', err);
return error(e);
}
// aqui deberiamos inicializar todas las apis
domain = new Domain(zimbra);
account = new Account(zimbra);
return success();
});
}
export function getDomain(name, by, attrs, success, error) {
console.log(domain);
if (domain) {
return domain.get(name, by, attrs,
(data) => {
// aqui formateamos la data que viene en "data"
const nuevoObj = {
dominio: 'el nombre del dominio'
}
return success(nuevoObj);
},
(err) => {
var e = handleError('getDomain', err);
error(e);
});
}
// probablemente esto lo que deba hacer es forzar un login
return error({message: 'Domain not initialized'});
}
export function getAllDomains(success, error) {
if (domain) {
return domain.getAll(
(data) => {
return success(data);
},
(err) => {
var e = handleError('getDomain', err);
error(e);
});
}
// probablemente esto lo que deba hacer es forzar un login
return error({message: 'Domain not initialized'});
}
export function getAllAccounts(success, error) {
if (account) {
return account.getAll(
(data) => {
return success(data);
},
(err) => {
var e = handleError('getDomain', err);
error(e);
});
}
// probablemente esto lo que deba hacer es forzar un login
return error({message: 'Domain not initialized'});
}
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See License.txt for license information.
import keyMirror from 'keymirror';
export default {
ActionTypes: keyMirror({
RECEIVED_ERROR: null
}),
PayloadSources: keyMirror({
SERVER_ACTION: null,
VIEW_ACTION: null
}),
RESERVED_TEAM_NAMES: [
'www',
'web',
'admin',
'support',
'notify',
'test',
'demo',
'mail',
'team',
'channel',
'internal',
'localhost',
'dockerhost',
'stag',
'post',
'cluster',
'api'
],
RESERVED_USERNAMES: [
'admin',
'root'
],
MONTHS: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Juio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
KeyCodes: {
UP: 38,
DOWN: 40,
LEFT: 37,
RIGHT: 39,
BACKSPACE: 8,
ENTER: 13,
ESCAPE: 27,
SPACE: 32,
TAB: 9
}
};
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
import Domain from './../zimbra/domain.js';
import Account from './../zimbra/account.js';
import DistributionList from './../zimbra/distribution_list.js';
export default class Dictionary {
constructor() {
this.zimbra_resources = this.ZimbraResources();
}
resourceToClass (resource) {
return this.zimbra_resources[resource].class_name;
}
classFactory (resource, object) {
const class_name = this.resourceToClass(resource);
return new class_name(object);
}
resourceResponseName (resource) {
return this.zimbra_resources[resource].response_name;
}
ZimbraResources() {
return {
domain: {
class_name: Domain,
response_name: 'domain'
},
account: {
class_name: Account,
response_name: 'account'
},
distributionlist: {
class_name: DistributionList,
response_name: 'dl'
}
};
}
}
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved. // Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import ZimbraAdmin from './zimbra_admin.jsx'; import Zimbra from './zimbra.js';
export default class Domain extends ZimbraAdmin { export default class Account extends Zimbra {
constructor(connection) { constructor(account_obj) {
super(connection, 'Domain'); super(account_obj);
} }
} }
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
import ZimbraAdmin from './zimbra_admin.jsx';
export default class Account extends ZimbraAdmin {
constructor(connection, name, id, attrs) {
super(connection, 'Account');
this.name = name;
this.id = id;
this.attrs = attrs;
}
}
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
export default class DistributionList {
constructor(dl_obj) {
this.name = dl_obj.name;
this.id = dl_obj.id;
this.attrs = dl_obj.a;
}
}
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
import ZimbraAdmin from './zimbra_admin.jsx';
export default class DistributionList extends ZimbraAdmin {
constructor(connection, name, id, attrs) {
super(connection, 'DistributionList');
this.param_object_name = 'dl';
this.name = name;
this.id = id;
this.attrs = attrs;
}
}
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
export default class Domain {
constructor(domain_obj) {
this.name = domain_obj.name;
this.id = domain_obj.id;
this.attrs = domain_obj.a;
}
}
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
export default class Zimbra {
constructor(resource_obj) {
this.name = resource_obj.name;
this.id = resource_obj.id;
this.attrs = resource_obj.a;
}
}
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
export default class zimbraAdmin {
constructor(connection, object_name) {
this.zimbra = connection;
this.object_name = object_name;
this.param_object_name = object_name.toLocaleLowerCase();
this.request = this.buildRequest();
this.params = this.buildParams();
}
return_error(err){
if (err) return error(err);
}
buildParams() {
return { namespace: 'zimbraAdmin', params: { [this.param_object_name]: {} } };
}
buildRequest() {
request = null;
this.zimbra.getRequest({}, (err, req) => {
if (err) return error(err);
request = req;
});
return request;
}
makeRequest(request_name, parse_response, success, error) {
const self = this;
this.params.name = `${request_name}Request`;
this.response_name = `${request_name}Response`;
this.request.addRequest(this.params, function(err){
if (err) {
return error(err);
}
const obj = Object.create(self);
obj.success = success;
obj.error = error;
self.zimbra.send(self.request, parse_response.bind(obj));
});
}
parseResponse(err, data) {
if (err) {
return this.error(err);
}
let response_object = data.get()[this.response_name][this.param_object_name];
return this.success(response_object);
}
parseAllResponse(err, data){
if (err) {
return this.error(err);
}
let response_object = data.get()[this.response_name][this.param_object_name];
return this.success(response_object);
}
attributesHandler() {
return {
get(target, key) {
if (target[key]) return target[key];
if (target.a[key]) return target.a[key];
return null;
}
};
}
requestParams() {
return this.params.params[this.param_object_name];
}
getAll(success, error) {
this.makeRequest(`GetAll${this.object_name}s`, this.parseAllResponse, success, error);
}
get(name, by, attrs, success, error) {
var params = this.requestParams();
params.attrs = attrs;
params.by = by;
params._content = name;
this.makeRequest(`Get${this.object_name}`, this.parseResponse, success, error);
}
}
(function () {
"use strict";
// Module systems magic dance.
/* istanbul ignore else */
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
// NodeJS
module.exports = chaiAsPromised;
} else if (typeof define === "function" && define.amd) {
// AMD
define(function () {
return chaiAsPromised;
});
} else {
/*global self: false */
// Other environment (usually <script> tag): plug in to global chai instance directly.
chai.use(chaiAsPromised);
// Expose as a property of the global object so that consumers can configure the `transferPromiseness` property.
self.chaiAsPromised = chaiAsPromised;
}
chaiAsPromised.transferPromiseness = function (assertion, promise) {
assertion.then = promise.then.bind(promise);
};
chaiAsPromised.transformAsserterArgs = function (values) {
return values;
};
function chaiAsPromised(chai, utils) {
var Assertion = chai.Assertion;
var assert = chai.assert;
function isLegacyJQueryPromise(thenable) {
// jQuery promises are Promises/A+-compatible since 3.0.0. jQuery 3.0.0 is also the first version
// to define the catch method.
return typeof thenable.catch !== "function" &&
typeof thenable.always === "function" &&
typeof thenable.done === "function" &&
typeof thenable.fail === "function" &&
typeof thenable.pipe === "function" &&
typeof thenable.progress === "function" &&
typeof thenable.state === "function";
}
function assertIsAboutPromise(assertion) {
if (typeof assertion._obj.then !== "function") {
throw new TypeError(utils.inspect(assertion._obj) + " is not a thenable.");
}
if (isLegacyJQueryPromise(assertion._obj)) {
throw new TypeError("Chai as Promised is incompatible with thenables of jQuery<3.0.0, sorry! Please " +
"upgrade jQuery or use another Promises/A+ compatible library (see " +
"http://promisesaplus.com/).");
}
}
function method(name, asserter) {
utils.addMethod(Assertion.prototype, name, function () {
assertIsAboutPromise(this);
return asserter.apply(this, arguments);
});
}
function property(name, asserter) {
utils.addProperty(Assertion.prototype, name, function () {
assertIsAboutPromise(this);
return asserter.apply(this, arguments);
});
}
function doNotify(promise, done) {
promise.then(function () { done(); }, done);
}
// These are for clarity and to bypass Chai refusing to allow `undefined` as actual when used with `assert`.
function assertIfNegated(assertion, message, extra) {
assertion.assert(true, null, message, extra.expected, extra.actual);
}
function assertIfNotNegated(assertion, message, extra) {
assertion.assert(false, message, null, extra.expected, extra.actual);
}
function getBasePromise(assertion) {
// We need to chain subsequent asserters on top of ones in the chain already (consider
// `eventually.have.property("foo").that.equals("bar")`), only running them after the existing ones pass.
// So the first base-promise is `assertion._obj`, but after that we use the assertions themselves, i.e.
// previously derived promises, to chain off of.
return typeof assertion.then === "function" ? assertion : assertion._obj;
}
// Grab these first, before we modify `Assertion.prototype`.
var propertyNames = Object.getOwnPropertyNames(Assertion.prototype);
var propertyDescs = {};
propertyNames.forEach(function (name) {
propertyDescs[name] = Object.getOwnPropertyDescriptor(Assertion.prototype, name);
});
property("fulfilled", function () {
var that = this;
var derivedPromise = getBasePromise(that).then(
function (value) {
that._obj = value;
assertIfNegated(that,
"expected promise not to be fulfilled but it was fulfilled with #{act}",
{ actual: value });
return value;
},
function (reason) {
assertIfNotNegated(that,
"expected promise to be fulfilled but it was rejected with #{act}",
{ actual: reason });
}
);
chaiAsPromised.transferPromiseness(that, derivedPromise);
});
property("rejected", function () {
var that = this;
var derivedPromise = getBasePromise(that).then(
function (value) {
that._obj = value;
assertIfNotNegated(that,
"expected promise to be rejected but it was fulfilled with #{act}",
{ actual: value });
return value;
},
function (reason) {
assertIfNegated(that,
"expected promise not to be rejected but it was rejected with #{act}",
{ actual: reason });
// Return the reason, transforming this into a fulfillment, to allow further assertions, e.g.
// `promise.should.be.rejected.and.eventually.equal("reason")`.
return reason;
}
);
chaiAsPromised.transferPromiseness(that, derivedPromise);
});
method("rejectedWith", function (Constructor, message) {
var desiredReason = null;
var constructorName = null;
if (Constructor instanceof RegExp || typeof Constructor === "string") {
message = Constructor;
Constructor = null;
} else if (Constructor && Constructor instanceof Error) {
desiredReason = Constructor;
Constructor = null;
message = null;
} else if (typeof Constructor === "function") {
constructorName = (new Constructor()).name;
} else {
Constructor = null;
}
var that = this;
var derivedPromise = getBasePromise(that).then(
function (value) {
var assertionMessage = null;
var expected = null;
if (Constructor) {
assertionMessage = "expected promise to be rejected with #{exp} but it was fulfilled with " +
"#{act}";
expected = constructorName;
} else if (message) {
var verb = message instanceof RegExp ? "matching" : "including";
assertionMessage = "expected promise to be rejected with an error " + verb + " #{exp} but it " +
"was fulfilled with #{act}";
expected = message;
} else if (desiredReason) {
assertionMessage = "expected promise to be rejected with #{exp} but it was fulfilled with " +
"#{act}";
expected = desiredReason;
}
that._obj = value;
assertIfNotNegated(that, assertionMessage, { expected: expected, actual: value });
},
function (reason) {
if (Constructor) {
that.assert(reason instanceof Constructor,
"expected promise to be rejected with #{exp} but it was rejected with #{act}",
"expected promise not to be rejected with #{exp} but it was rejected with #{act}",
constructorName,
reason);
}
var reasonMessage = utils.type(reason) === "object" && "message" in reason ?
reason.message :
"" + reason;
if (message && reasonMessage !== null && reasonMessage !== undefined) {
if (message instanceof RegExp) {
that.assert(message.test(reasonMessage),
"expected promise to be rejected with an error matching #{exp} but got #{act}",
"expected promise not to be rejected with an error matching #{exp}",
message,
reasonMessage);
}
if (typeof message === "string") {
that.assert(reasonMessage.indexOf(message) !== -1,
"expected promise to be rejected with an error including #{exp} but got #{act}",
"expected promise not to be rejected with an error including #{exp}",
message,
reasonMessage);
}
}
if (desiredReason) {
that.assert(reason === desiredReason,
"expected promise to be rejected with #{exp} but it was rejected with #{act}",
"expected promise not to be rejected with #{exp}",
desiredReason,
reason);
}
}
);
chaiAsPromised.transferPromiseness(that, derivedPromise);
});
property("eventually", function () {
utils.flag(this, "eventually", true);
});
method("notify", function (done) {
doNotify(getBasePromise(this), done);
});
method("become", function (value, message) {
return this.eventually.deep.equal(value, message);
});
////////
// `eventually`
// We need to be careful not to trigger any getters, thus `Object.getOwnPropertyDescriptor` usage.
var methodNames = propertyNames.filter(function (name) {
return name !== "assert" && typeof propertyDescs[name].value === "function";
});
methodNames.forEach(function (methodName) {
Assertion.overwriteMethod(methodName, function (originalMethod) {
return function () {
doAsserterAsyncAndAddThen(originalMethod, this, arguments);
};
});
});
var getterNames = propertyNames.filter(function (name) {
return name !== "_obj" && typeof propertyDescs[name].get === "function";
});
getterNames.forEach(function (getterName) {
// Chainable methods are things like `an`, which can work both for `.should.be.an.instanceOf` and as
// `should.be.an("object")`. We need to handle those specially.
var isChainableMethod = Assertion.prototype.__methods.hasOwnProperty(getterName);
if (isChainableMethod) {
Assertion.overwriteChainableMethod(
getterName,
function (originalMethod) {
return function() {
doAsserterAsyncAndAddThen(originalMethod, this, arguments);
};
},
function (originalGetter) {
return function() {
doAsserterAsyncAndAddThen(originalGetter, this);
};
}
);
} else {
Assertion.overwriteProperty(getterName, function (originalGetter) {
return function () {
doAsserterAsyncAndAddThen(originalGetter, this);
};
});
}
});
function doAsserterAsyncAndAddThen(asserter, assertion, args) {
// Since we're intercepting all methods/properties, we need to just pass through if they don't want
// `eventually`, or if we've already fulfilled the promise (see below).
if (!utils.flag(assertion, "eventually")) {
return asserter.apply(assertion, args);
}
var derivedPromise = getBasePromise(assertion).then(function (value) {
// Set up the environment for the asserter to actually run: `_obj` should be the fulfillment value, and
// now that we have the value, we're no longer in "eventually" mode, so we won't run any of this code,
// just the base Chai code that we get to via the short-circuit above.
assertion._obj = value;
utils.flag(assertion, "eventually", false);
return args ? chaiAsPromised.transformAsserterArgs(args) : args;
}).then(function (args) {
asserter.apply(assertion, args);
// Because asserters, for example `property`, can change the value of `_obj` (i.e. change the "object"
// flag), we need to communicate this value change to subsequent chained asserters. Since we build a
// promise chain paralleling the asserter chain, we can use it to communicate such changes.
return assertion._obj;
});
chaiAsPromised.transferPromiseness(assertion, derivedPromise);
}
///////
// Now use the `Assertion` framework to build an `assert` interface.
var originalAssertMethods = Object.getOwnPropertyNames(assert).filter(function (propName) {
return typeof assert[propName] === "function";
});
assert.isFulfilled = function (promise, message) {
return (new Assertion(promise, message)).to.be.fulfilled;
};
assert.isRejected = function (promise, toTestAgainst, message) {
if (typeof toTestAgainst === "string") {
message = toTestAgainst;
toTestAgainst = undefined;
}
var assertion = (new Assertion(promise, message));
return toTestAgainst !== undefined ? assertion.to.be.rejectedWith(toTestAgainst) : assertion.to.be.rejected;
};
assert.becomes = function (promise, value, message) {
return assert.eventually.deepEqual(promise, value, message);
};
assert.doesNotBecome = function (promise, value, message) {
return assert.eventually.notDeepEqual(promise, value, message);
};
assert.eventually = {};
originalAssertMethods.forEach(function (assertMethodName) {
assert.eventually[assertMethodName] = function (promise) {
var otherArgs = Array.prototype.slice.call(arguments, 1);
var customRejectionHandler;
var message = arguments[assert[assertMethodName].length - 1];
if (typeof message === "string") {
customRejectionHandler = function (reason) {
throw new chai.AssertionError(message + "\n\nOriginal reason: " + utils.inspect(reason));
};
}
var returnedPromise = promise.then(
function (fulfillmentValue) {
return assert[assertMethodName].apply(assert, [fulfillmentValue].concat(otherArgs));
},
customRejectionHandler
);
returnedPromise.notify = function (done) {
doNotify(returnedPromise, done);
};
return returnedPromise;
};
});
}
}());
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
'url': 'http://localhost', 'url': 'http://localhost',
'user': 'user', 'user': 'user',
'password':'pass'}); 'password':'pass'});
api.client.options.timeout = 1000; api.client.options.timeout = 10000;
api.login(null, function(err){ api.login(null, function(err){
let error = api.handleError(err); let error = api.handleError(err);
expect(error.constructor.name).to.equal('Error'); expect(error.constructor.name).to.equal('Error');
...@@ -61,24 +61,51 @@ ...@@ -61,24 +61,51 @@
it('should get all domains', function() { it('should get all domains', function() {
var api = new ZimbraAdminApi(auth_data); var api = new ZimbraAdminApi(auth_data);
var success = function(d){ api.getAllDomains(function(err, data){
d.forEach(function(v){ if (err) console.log(err);
console.log(v.name); expect(data[0].constructor.name).to.equal('Domain');
})
};
var error = function(d){console.log(d);};
// sucess, err (Why)?
api.getAllAccounts(function(data, err){
if (err) return console.log(err);
data.forEach(function(v){
console.log(v.id + ' ' + v.name);
})
}); });
});
it('should get all accounts', function() {
var api = new ZimbraAdminApi(auth_data);
api.getAllAccounts(function(err, data){
if (err) console.log(err);
expect(data[0].constructor.name).to.equal('Account');
});
});
it('should get all distribution_lists', function() {
var api = new ZimbraAdminApi(auth_data);
api.getAllDistributionLists(function(err, data){
if (err) console.log(err);
expect(data[0].constructor.name).to.equal('DistributionList');
});
}); });
});
})();
describe('Using callbacks', function() { // it('should get all domains', function() {
// var api = new ZimbraAdminApi(auth_data);
// var success = function(d){
// d.forEach(function(v){
// console.log(v.name);
// })
// };
// var error = function(d){console.log(d);};
// // sucess, err (Why)?
// api.getAllAccounts(function(data, err){
// if (err) return console.log(err);
// data.forEach(function(v){
// console.log(v.id + ' ' + v.name);
// })
// });
//
// });
//
//
// describe('Using callbacks', function() {
// it('should get a track', function() { // it('should get a track', function() {
// var callback = sinon.spy(); // var callback = sinon.spy();
...@@ -131,6 +158,3 @@ ...@@ -131,6 +158,3 @@
// expect(that.requests).to.have.length(1); // expect(that.requests).to.have.length(1);
// expect(that.requests[0].url).to.equal('https://api.spotify.com/v1/albums/0sNOF9WDwhWunNAHPD3Baj/tracks'); // expect(that.requests[0].url).to.equal('https://api.spotify.com/v1/albums/0sNOF9WDwhWunNAHPD3Baj/tracks');
// }); // });
});
});
})();
...@@ -28,11 +28,11 @@ var config = { ...@@ -28,11 +28,11 @@ var config = {
module: { module: {
loaders: [ loaders: [
{ {
test: /\.jsx?$/, test: /\.(js|jsx)?$/,
loader: 'babel', loader: 'babel',
exclude: /(node_modules)/, exclude: /(node_modules)/,
query: { query: {
presets: ['es2015'],
plugins: ['transform-runtime'], plugins: ['transform-runtime'],
cacheDirectory: DEV cacheDirectory: DEV
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment