How to use launchdarkly-js-test-helpers - 7 common examples

To help you get started, we’ve selected a few launchdarkly-js-test-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github launchdarkly / node-server-sdk / test / feature_store_test_base.js View on Github external
it('handles upsert race condition against other client with lower version', async () => {
    var myDesiredVersion = 10;
    var competingStoreVersions = [ 2, 3, 4 ]; // proves that we can retry multiple times if necessary

    var myStore = makeStoreWithHook(writeCompetingVersions(competingStoreVersions));

    await initStore(myStore);
    await promisifySingle(myStore.upsert)(dataKind.features, makeFlagWithVersion(myDesiredVersion));
    var result = await promisifySingle(myStore.get)(dataKind.features, flagKey);
    expect(result.version).toEqual(myDesiredVersion);
  });
github launchdarkly / node-server-sdk / test / feature_store_test_base.js View on Github external
it('does not get nonexisting feature', async () => {
    var store = await initedStore();
    var result = await promisifySingle(store.get)(dataKind.features, 'biz');
    expect(result).toBe(null);
  });
github launchdarkly / node-server-sdk / test / feature_store_test_base.js View on Github external
it('does not delete with older version', async () => {
    var store = await initedStore();
    await promisifySingle(store.delete)(dataKind.features, feature1.key, feature1.version - 1);
    var result = await promisifySingle(store.get)(dataKind.features, feature1.key);
    expect(result).not.toBe(null);
  });
github launchdarkly / node-server-sdk / test / feature_store_test_base.js View on Github external
it('init() completely replaces previous data', async () => {
    var store = makeStore();
    var flags = {
      first: { key: 'first', version: 1 },
      second: { key: 'second', version: 1 }
    };
    var segments = { first: { key: 'first', version: 2 } };
    var initData = {};
    initData[dataKind.features.namespace] = flags;
    initData[dataKind.segments.namespace] = segments;

    await promisifySingle(store.init)(initData);
    var items = await promisifySingle(store.all)(dataKind.features);
    expect(items).toEqual(flags);
    items = await promisifySingle(store.all)(dataKind.segments);
    expect(items).toEqual(segments);

    var newFlags = { first: { key: 'first', version: 3 } };
    var newSegments = { first: { key: 'first', version: 4 } };
    var initData = {};
    initData[dataKind.features.namespace] = newFlags;
    initData[dataKind.segments.namespace] = newSegments;

    await promisifySingle(store.init)(initData);
    items = await promisifySingle(store.all)(dataKind.features);
    expect(items).toEqual(newFlags);
    items = await promisifySingle(store.all)(dataKind.segments);
    expect(items).toEqual(newSegments);
  });
github launchdarkly / node-server-sdk / test / feature_store_test_base.js View on Github external
it(desc, async () => {
        var store1 = makeStore();
        var store2 = makeStore();

        var result = await promisifySingle(store1.initialized)();
        expect(result).toBe(false);

        await promisifySingle(store2.init)(initData);
        result = await promisifySingle(store1.initialized)();
        expect(result).toBe(true);
      });
    }
github launchdarkly / node-server-sdk / test / feature_store_test_base.js View on Github external
async function initStore(store) {
    var allData = { features: {} };
    allData['features'][flagKey] = makeFlagWithVersion(initialVersion);
    await promisifySingle(store.init)(allData);
  }
github launchdarkly / node-server-sdk / test / feature_store_test_base.js View on Github external
async function initedStore() {
    var store = makeStore();
    var initData = {};
    initData[dataKind.features.namespace] = {
      'foo': feature1,
      'bar': feature2
    };
    await promisifySingle(store.init)(initData);
    return store;
  }

launchdarkly-js-test-helpers

LaunchDarkly JavaScript test utilities

Apache-2.0
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Popular launchdarkly-js-test-helpers functions