Sha256: e08517384ac77a8bce4a927da305657b67156c634367401dd74860f8b5322173

Contents?: true

Size: 1.92 KB

Versions: 56

Compression:

Stored size: 1.92 KB

Contents

import {
  quantitiesRequestSuccessResponse,
  loadQuantitiesSuccessActionPayload,
} from './subscriptions.fixtures';
import {
  filterRHSubscriptions,
  manifestExists,
  selectSubscriptionsQuantitiesFromResponse,
} from '../SubscriptionHelpers';

describe('Subscription helper', () => {
  it('should filter subscriptions without upstream_pool_id', () => {
    const subscriptions = [
      {
        key: 'sub-1',
        available: 3,
      },
      {
        key: 'sub-2',
        available: 4,
        upstream_pool_id: ' ',
      },
      {
        key: 'sub-3',
        available: -5,
        upstream_pool_id: ' ',
      },
      {
        key: 'sub-4',
        available: -1,
      },
    ];

    const filteredSubscriptions = filterRHSubscriptions(subscriptions);

    expect(filteredSubscriptions).toMatchSnapshot();
  });

  it('should filter redhat subscriptions', () => {
    const subscriptions = [
      {
        key: 'sub-1',
        available: 0,
        upstream_pool_id: ' ',
      },
      {
        key: 'sub-2',
        available: 4,
        upstream_pool_id: ' ',
      },
      {
        key: 'sub-3',
        available: -5,
        upstream_pool_id: ' ',
      },
      {
        key: 'sub-4',
        available: 100,
        upstream_pool_id: ' ',
      },
    ];

    const filteredSubscriptions = filterRHSubscriptions(subscriptions);

    expect(filteredSubscriptions).toMatchSnapshot();
  });

  it('should check if manifest exists in an organization', () => {
    const upstreamConsumer = 'some-upstream-consumer';

    expect(manifestExists({
      owner_details: { upstreamConsumer },
    })).toBe(upstreamConsumer);

    expect(manifestExists({})).toBeFalsy();
  });

  it('should select subscriptions-quantities from api response', () => {
    const quantities =
      selectSubscriptionsQuantitiesFromResponse(quantitiesRequestSuccessResponse);

    expect(quantities).toEqual(loadQuantitiesSuccessActionPayload);
  });
});

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
katello-3.16.2 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.1.2 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.1.1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0.rc5.1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0.rc5 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0.rc4.1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.15.3.1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.15.3 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0.rc4 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0.rc3.1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.15.2 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0.rc3 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0.rc2.1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0.rc2 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.15.1.1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0.rc1.1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.15.1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js
katello-3.16.0.rc1 webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js