polkadot-js/apps

View on GitHub
packages/page-bounties/src/helpers/determineUnassignCuratorAction.spec.ts

Summary

Maintainability
A
3 hrs
Test Coverage
// Copyright 2017-2024 @polkadot/app-bounties authors & contributors
// SPDX-License-Identifier: Apache-2.0

/// <reference types="@polkadot/dev-test/globals.d.ts" />

import { createAugmentedApi } from '@polkadot/test-support/api';
import { BountyFactory } from '@polkadot/test-support/creation/bounties';
import { BN } from '@polkadot/util';

import { determineUnassignCuratorAction } from './determineUnassignCuratorAction.js';

describe('adjust slash curator component for', () => {
  const augmentedApi = createAugmentedApi();
  const { aBountyStatus } = new BountyFactory(augmentedApi);

  it('Member in Active state', () => {
    const displayAs = determineUnassignCuratorAction(['Member'], aBountyStatus('Active'));

    expect(displayAs).toEqual(['SlashCuratorMotion']);
  });

  it('Member in CuratorProposed state', () => {
    const displayAs = determineUnassignCuratorAction(['Member'], aBountyStatus('CuratorProposed'));

    expect(displayAs).toEqual(['UnassignCurator']);
  });

  it('Member in PendingPayout state', () => {
    const displayAs = determineUnassignCuratorAction(['Member'], aBountyStatus('PendingPayout'));

    expect(displayAs).toEqual(['SlashCuratorMotion']);
  });

  it('User in Active state with update due blocks remaining', () => {
    const displayAs = determineUnassignCuratorAction(['User'], aBountyStatus('Active'), new BN('1'));

    expect(displayAs).toEqual([]);
  });

  it('User in Active state with no updated state', () => {
    const displayAs = determineUnassignCuratorAction(['User'], aBountyStatus('Active'), new BN('-1'));

    expect(displayAs).toEqual(['SlashCuratorAction']);
  });

  it('Member and User in Active state with no updated state', () => {
    const displayAs = determineUnassignCuratorAction(['User', 'Member'], aBountyStatus('Active'), new BN('-1'));

    expect(displayAs).toEqual(expect.arrayContaining(['SlashCuratorAction', 'SlashCuratorMotion']));
  });

  it('Curator in Active state', () => {
    const displayAs = determineUnassignCuratorAction(['Curator'], aBountyStatus('PendingPayout'));

    expect(displayAs).toEqual([]);
  });

  it('User in Active state', () => {
    const displayAs = determineUnassignCuratorAction(['User'], aBountyStatus('PendingPayout'));

    expect(displayAs).toEqual([]);
  });
});