All files / src/__tests__ fake-resource-with-custom-prefix.ts

100% Statements 26/26
85.71% Branches 6/7
100% Functions 5/5
100% Lines 25/25

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42  1x 1x 1x 1x 1x 1x   1x     1x 1x 1x 1x 1x 1x 1x 1x               1x 1x 1x   1x 2x 1x         1x 1x      
import Base, {ResourcePath} from '../base-rest-resource';
import {SessionInterface} from '../auth/session/types';
import {ApiVersion} from '../base-types';
 
interface FakeResourceWithCustomPrefixFindArgs {
  session: SessionInterface;
  id: string | number;
}
 
export default class FakeResourceWithCustomPrefix extends Base {
  public static API_VERSION = ApiVersion.Unstable;
  protected static NAME = 'fake_resource_with_custom_prefix';
  protected static PLURAL_NAME = 'fake_resource_with_custom_prefixes';
  protected static CUSTOM_PREFIX = '/admin/custom_prefix';
 
  protected static HAS_ONE = {};
  protected static HAS_MANY = {};
 
  protected static PATHS: ResourcePath[] = [
    {
      http_method: 'get',
      operation: 'get',
      ids: ['id'],
      path: 'fake_resource_with_custom_prefix/<id>.json',
    },
  ];
 
  public static find = async ({
    session,
    id,
  }: FakeResourceWithCustomPrefixFindArgs): Promise<FakeResourceWithCustomPrefix | null> => {
    const result = await FakeResourceWithCustomPrefix.baseFind({
      session,
      urlIds: {id},
    });
    return result ? (result[0] as FakeResourceWithCustomPrefix) : null;
  };
 
  id?: number | string | null;
  attribute?: string | null;
}