it('should handle properly situation when email returned from facebook is empty', function (done) { var $u = createUser(); $u.profile._json = { email: null }; userRepo.createAccFromFacebook($u.accessToken, $u.refreshToken, $u.profile) .then(function(user) { expect(user).to.be.a('object'); expect(user.facebookId).to.be($u.uniqueness.toString()); expect(user.password).to.be(null); expect(user.email).to.be(user.facebookId + '@facebook.com'); done(); }); });
describe('Config', function() { it('default config', function() { var settings = main.FeedManager.settings; var expected = require('../getstream.js').config; expect(settings).to.eql(expected); }); });
it('formatParams should ok', function () { const formatParams = rpc.__get__('formatParams'); expect(formatParams({'hello': 'world'})).to.be.eql({ Hello: 'world' }); });
it('should create properly a new user from github with location', function (done) { var $u = createUser(); $u.profile.emails = [ {value: $u.email} ]; $u.profile._json = {location: 'Warsaw'}; userRepo.createAccFromGithub($u.accessToken, $u.tokenSecret, $u.profile) .then(function(user) { expect(user).to.be.a('object'); expect(user.profile).to.be.a('object'); expect(user.profile.location).to.be('Warsaw'); done(); }); });
it('Bone.join().count()', async function() { const query = Post.find({ title: ['Archangel Tyrael', 'New Post'] }); const count = await query.count(); const posts = await query.order('title').with('attachment'); expect(posts.length).to.equal(count); expect(posts[0]).to.be.a(Post); expect(posts[0].title).to.equal('Archangel Tyrael'); expect(posts[0].attachment).to.be(null); expect(posts[1].attachment).to.be.an(Attachment); expect(posts[1].attachment.postId).to.equal(posts[1].id); });
it('should create properly a new user from google with picture', function (done) { var $u = createUser(); $u.profile._json.image = {url: 'PICTURE_URL'}; userRepo.createAccFromGoogle($u.accessToken, $u.tokenSecret, $u.profile) .then(function(user) { expect(user).to.be.a('object'); expect(user.profile).to.be.a('object'); expect(user.profile.picture).to.be('PICTURE_URL'); done(); }); });
it('listServices should ok', async function () { const response = await client.listServices(); expect(response.data).to.be.ok(); expect(response.data.services).to.be.ok(); expect(response.data.services.length).to.above(0); const [service] = response.data.services; expect(service).to.have.property('serviceName'); });
it('bone.save() should UPDATE when primaryKey is defined and saved before', async function() { const post = await Post.create({ id: 1, title: 'New Post', createdAt: new Date(2010, 9, 11) }); const updatedAtWas = post.updatedAt; post.title = 'Skeleton King'; await post.save(); const foundPost = await Post.findOne({ title: 'Skeleton King' }); expect(foundPost.id).to.equal(post.id); expect(foundPost.updatedAt.getTime()).to.be.above(updatedAtWas.getTime()); });
it('should create properly a new user where there is no email returned from GitHub', function (done) { var $u = createUser(); $u.profile.emails = [ {value: ''} ]; userRepo.createAccFromGithub($u.accessToken, $u.tokenSecret, $u.profile) .then(function(user) { expect(user).to.be.a('object'); expect(user.profile).to.be.a('object'); expect(user.email).to.be($u.uniqueness + '@github.com'); done(); }); });
it('getCanonicalizedResource should ok', function () { const getCanonicalizedResource = roa.__get__('getCanonicalizedResource'); expect(getCanonicalizedResource('/', {})).to.be('/'); expect(getCanonicalizedResource('/', {key: 'value'})).to.be('/?key=value'); const q = {key: 'value', 'key1': 'value2'}; expect(getCanonicalizedResource('/', q)).to.be('/?key=value&key1=value2'); });
it('buildAuthorization should ok', function () { const client = new ROAClient({ endpoint: 'https://ecs.aliyuncs.com/', apiVersion: '1.0', accessKeyId: 'accessKeyId', accessKeySecret: 'accessKeySecret', securityToken: 'securityToken' }); const auth = client.buildAuthorization('stringtosign'); expect(auth).to.be('acs accessKeyId:9/j11e+L9jW8mC9eUA23Wn3c0fs='); });