beforeEach( () => { selector = jest.fn( ( [ posts ], siteId ) => Object.values( posts ).filter( ( p ) => p.siteId === siteId ) ); getDependents = jest.fn( ( state ) => [ state.posts ] ); getSitePosts = treeSelect( getDependents, selector ); } );
test('The schemas should be accessible via getSchemas', t => { t.plan(1) const fastify = Fastify() const schemas = { id: { $id: 'id', my: 'schema' }, abc: { $id: 'abc', my: 'schema' }, bcd: { $id: 'bcd', my: 'schema', properties: { a: 'a', b: 1 } } } Object.values(schemas).forEach(schema => { fastify.addSchema(schema) }) t.deepEqual(fastify.getSchemas(), schemas) })
/** * @description Get all discovered devices, and if device already created, the Gladys device. * @returns {*} Discovered devices. * @example * getDiscoveredDevices() */ function getDiscoveredDevices() { const discovered = Object.values(this.mqttDevices).map((d) => { return this.mergeWithExistingDevice(d); }); return discovered; }
/** * @param {object} list of all the keystone adapters passed in while configuring the app. * @returns {Promise[]} array of Promises for dropping the keystone databases. */ function dropAllDatabases(adapters) { return Promise.all(Object.values(adapters).map(adapter => adapter.dropDatabase())); }
it('updates the list of brokers', async () => { expect(brokerPool.brokers).toEqual({}) await brokerPool.refreshMetadata([topicName]) expect(Object.keys(brokerPool.brokers).sort()).toEqual(['0', '1', '2']) expect(Object.values(brokerPool.brokers)).toEqual( expect.arrayContaining([expect.any(Broker), expect.any(Broker), expect.any(Broker)]) ) })
const App = () => ( <Layout> <Switch> {Object.values(routes).map((route, index) => ( route.auth ? <RoutePrivate {...route} key={index} path={typeof route.path === 'function' ? route.path() : route.path}/> : <Route {...route} key={index} path={typeof route.path === 'function' ? route.path() : route.path}/> ))} <Route component={NotFound}/> </Switch> </Layout> )
it('includes the seed broker into the broker pool', async () => { await brokerPool.refreshMetadata([topicName]) const seed = brokerPool.seedBroker.connection const brokers = Object.values(brokerPool.brokers) const seedFromBrokerPool = brokers .map(b => b.connection) .find(b => b.host === seed.host && b.port === seed.port) expect(seedFromBrokerPool).toEqual(seed) })
async postConnect({ rels }) { this.rels = rels; Object.values(this.listAdapters).forEach(listAdapter => { listAdapter._postConnect({ rels }); }); if (!this.config.dropDatabase || process.env.NODE_ENV === 'production') { return []; } await this.dropDatabase(); return this._createTables(); }
const retrieveGlobalLinks = pluginsObj => { return Object.values(pluginsObj).reduce((acc, current) => { const links = get(current, ['settings', 'global', 'links'], null); if (links) { for (let i = 0; i < links.length; i++) { acc.push(links[i]); } } return acc; }, []); }
// Associate all model // Run `.associate` if it exists, // ie create relationships in the ORM Object.values(models) .filter((model) => typeof model.associate === 'function') .forEach((model) => model.associate(models));
const findComponentByGlobalId = globalId => { return Object.values(strapi.components).find( compo => compo.globalId === globalId ); }
/** * @returns {Array<import("../../types").TopicPartitions>} topicPartitions * Example: [{ topic: 'topic-name', partitions: [1, 2] }] */ assigned() { return Object.values(this.assignedPartitionsByTopic).map(({ topic, partitions }) => ({ topic, partitions: partitions.sort(), })) }
Object.values(commands).reduce( (memo, { spec }) => ({ ...spec, ...memo, }), // prettier-ignore { '--help': Boolean, '-h': '--help', '--version': Boolean, } )
/** * @param {object} list of all the keystone adapters passed in while configuring the app. * @returns {Promise[]} array of Promises for dropping the keystone databases. */ function dropAllDatabases(adapters) { return Promise.all(Object.values(adapters).map(adapter => adapter.dropDatabase())); }
/** * @description Get all discovered devices, and if device already created, the Gladys device. * @returns {*} Discovered devices. * @example * getDiscoveredDevices() */ function getDiscoveredDevices() { const discovered = Object.values(this.mqttDevices).map((d) => { return this.mergeWithExistingDevice(d); }); return discovered; }