Skip to content

Instantly share code, notes, and snippets.

@masciugo
Created May 18, 2017 13:12
Show Gist options
  • Save masciugo/625baac661c8b0a3d44c773ef94f2b9c to your computer and use it in GitHub Desktop.
Save masciugo/625baac661c8b0a3d44c773ef94f2b9c to your computer and use it in GitHub Desktop.
fennel-dev test file
import { assert } from 'chai';
import co from 'co';
import * as dav from '../../lib';
suite('accounts', function() {
suite('#create', function() {
let xhr;
setup(function() {
xhr = new dav.transport.Basic(
new dav.Credentials({
username: 'demo',
password: 'demo'
})
);
});
test('carddav', co.wrap(function *() {
let account = yield dav.createAccount({
server: 'http://127.0.0.1:8888',
xhr: xhr,
accountType: 'carddav',
loadObjects: true
});
assert.instanceOf(account, dav.Account);
assert.instanceOf(account.credentials, dav.Credentials);
assert.strictEqual(account.credentials.username, 'demo');
assert.strictEqual(account.credentials.password, 'demo');
assert.strictEqual(account.server, 'http://127.0.0.1:8888');
assert.strictEqual(account.rootUrl, 'http://127.0.0.1:8888/');
assert.strictEqual(
account.principalUrl,
'http://127.0.0.1:8888/principals/demo/'
);
assert.strictEqual(
account.homeUrl,
'http://127.0.0.1:8888/addressbooks/demo/'
);
let addressBooks = account.addressBooks;
assert.operator(addressBooks.length, '>', 0);
let addressBook = addressBooks[0];
assert.instanceOf(addressBook, dav.AddressBook);
assert.strictEqual(addressBook.displayName, 'default address book');
assert.strictEqual(
addressBook.url,
'http://127.0.0.1:8888/addressbooks/demo/default/'
);
assert.typeOf(addressBook.ctag, 'string');
assert.isArray(addressBook.objects);
assert.lengthOf(addressBook.objects, 0);
assert.isArray(addressBook.reports);
assert.include(addressBook.reports, 'addressbook-query');
assert.isArray(addressBook.resourcetype);
assert.include(addressBook.resourcetype, 'addressbook');
assert.typeOf(addressBook.syncToken, 'string');
assert.operator(addressBook.syncToken.length, '>', 0);
}));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment