UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

62 lines 2.17 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const no_logger_1 = __importDefault(require("../../../../test/fixtures/no-logger")); const database_init_1 = __importDefault(require("../../../../test/e2e/helpers/database-init")); let stores; let db; let eventStore; let usersStore; let featureCollaboratorsReadModel; beforeAll(async () => { db = await (0, database_init_1.default)('feature_collaborators_read_model', no_logger_1.default); stores = db.stores; eventStore = stores.eventStore; usersStore = stores.userStore; featureCollaboratorsReadModel = stores.featureCollaboratorsReadModel; }); afterAll(async () => { await db.destroy(); }); test('Should return collaborators according to their activity order', async () => { const user1 = await usersStore.insert({ name: 'User One', email: 'user1@example.com', }); const user2 = await usersStore.insert({ name: 'User Two', email: 'user2@example.com', }); // first event on our feature await eventStore.store({ featureName: 'featureA', createdByUserId: user1.id, type: 'feature-created', createdBy: 'irrelevant', ip: '::1', }); // first event on another feature await eventStore.store({ featureName: 'featureB', createdByUserId: user1.id, type: 'feature-created', createdBy: 'irrelevant', ip: '::1', }); // second event on our feature await eventStore.store({ featureName: 'featureA', createdByUserId: user2.id, type: 'feature-updated', createdBy: 'irrelevant', ip: '::1', }); const collaborators = await featureCollaboratorsReadModel.getFeatureCollaborators('featureA'); expect(collaborators).toMatchObject([ { id: 2, name: 'User Two', imageUrl: expect.any(String) }, { id: 1, name: 'User One', imageUrl: expect.any(String) }, ]); }); //# sourceMappingURL=feature-collaborators-read-model.test.js.map