it('first with error', function (done) { const query = new Parse.Query(BoxedNumber); query.equalTo('$foo', 'bar'); query .first() .then(done.fail) .catch((e) => expect(e.code).toBe(Parse.Error.INVALID_KEY_NAME)) .then(done); });
const getModeratorsInCommunity = (communityId: string, options: Options): Promise<Array<string>> => { return ( db .table('usersCommunities') .getAll([communityId, true], { index: 'communityIdAndIsModerator' }) .skip(options.after || 0) .limit(options.first || 25) .map(userCommunity => userCommunity('userId')) .run() ); }
/** * The role of the member with the highest position * @type {Role} * @readonly */ get highest() { return this._roles.reduce((prev, role) => (role.comparePositionTo(prev) > 0 ? role : prev), this._roles.first()); }
it('can push unsubscribe response', function() { const parseWebSocket = { send: jasmine.createSpy('send'), }; const client = new Client(1, parseWebSocket); client.pushUnsubscribe(2); const lastCall = parseWebSocket.send.calls.first(); const messageJSON = JSON.parse(lastCall.args[0]); expect(messageJSON.op).toBe('unsubscribed'); expect(messageJSON.clientId).toBe(1); expect(messageJSON.requestId).toBe(2); });
/* * Helper to parse a command into useful metadataz */ const parseCmd = meta => _.merge({}, meta, { bin: _.trimEnd(path.basename(_.first(meta._), '"')), cmd: meta._[1], args: _.drop(meta._, 2), })
it('should call onChange when text input changes', () => { const onChange = jest.fn(); const wrapper = shallow(<FuelSavingsForm onSaveClick={jest.fn()} onChange={onChange} fuelSavings={getFuelSavings()} />); const changeEvent = { target: { name: 'newMpg', value: '20' } }; expect(onChange).not.toBeCalled(); wrapper.find(FuelSavingsTextInput).first().simulate('change', changeEvent); expect(onChange).toBeCalledWith(changeEvent); });
function userForSessionToken(sessionToken) { var q = new _node.default.Query('_Session'); q.equalTo('sessionToken', sessionToken); return q.first({ useMasterKey: true }).then(function (session) { if (!session) { return Promise.reject('No session found for session token'); } return session.get('user'); }); }
it('should not get PII via API with Find', done => { Parse.User.logOut().then(() => new Parse.Query(Parse.User).first().then(fetchedUser => { expect(fetchedUser.get('email')).toBe(undefined); expect(fetchedUser.get('zip')).toBe(undefined); expect(fetchedUser.get('ssn')).toBe(undefined); done(); }) ); });
const getBlockedUsersInCommunity = (communityId: string, options: Options): Promise<Array<string>> => { return ( db .table('usersCommunities') .getAll([communityId, false], { index: 'communityIdAndIsMember' }) .filter({ isBlocked: true }) .skip(options.after || 0) .limit(options.first || 25) .map(userCommunity => userCommunity('userId')) .run() ); }
it('should not alter select', done => { const obj0 = new Parse.Object('MyObject') .set('white', true) .set('black', true); obj0.save().then(() => { new Parse.Query('MyObject').first().then(result => { expect(result.get('white')).toBe(true); expect(result.get('black')).toBe(true); done(); }); }); });
it('should be able to get own PII via API with Find', done => { return new Parse.Query(Parse.User).first().then(fetchedUser => { expect(fetchedUser.get('email')).toBe(EMAIL); expect(fetchedUser.get('zip')).toBe(ZIP); expect(fetchedUser.get('ssn')).toBe(SSN); done(); }); });
const getOwnersInCommunity = ( communityId: string, options: Options ): Promise<Array<string>> => { return db .table('usersCommunities') .getAll([communityId, true], { index: 'communityIdAndIsOwner' }) .skip(options.after || 0) .limit(options.first || 25) .map(userCommunity => userCommunity('userId')) .run(); }
it('should not get PII via API with Find', done => { return Parse.User.logOut().then(() => new Parse.Query(Parse.User).first().then(fetchedUser => { expect(fetchedUser.get('email')).toBe(undefined); expect(fetchedUser.get('zip')).toBe(ZIP); expect(fetchedUser.get('ssn')).toBe(SSN); done(); }) ); });
it('should get PII via API with Find using master key', done => { Parse.User.logOut().then(() => new Parse.Query(Parse.User) .first({ useMasterKey: true }) .then(fetchedUser => { expect(fetchedUser.get('email')).toBe(EMAIL); expect(fetchedUser.get('zip')).toBe(ZIP); expect(fetchedUser.get('ssn')).toBe(SSN); done(); }) ); });
it('should get PII via API with Find using master key', done => { Parse.User.logOut().then(() => new Parse.Query(Parse.User) .first({ useMasterKey: true }) .then(fetchedUser => { expect(fetchedUser.get('email')).toBe(EMAIL); expect(fetchedUser.get('zip')).toBe(ZIP); expect(fetchedUser.get('ssn')).toBe(SSN); done(); }) ); });