# All files / src/test-cases entities.ts

100% Statements 22/22
100% Branches 2/2
100% Functions 6/6
100% Lines 18/18

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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    531x

    1x

    1x
    1x
    1x
    1x

    1x
    1x
    1x

    1x
    1x
    2645x
    5x

    5x

    5x

    5290x

    5405x

    5x

     import {
      BASE_PATH,
      EMPTY_TRANSLATIONS_PATH,
      WS_TESTING_PATH
    } from '../../test/common';
    import {
      CONCEPT_TYPE_ENTITY_DOMAIN,
      CONCEPT_TYPE_ENTITY_SET,
      isEntityDomainOrSet,
      RESERVED_CONCEPT,
      RESERVED_CONCEPT_TYPE,
      RESERVED_DOMAIN,
      RESERVED_DRILL_UP
    } from 'ddf-query-validator';

    import * as map from 'lodash.map';
    import * as flatMap from 'lodash.flatmap';
    import * as isNil from 'lodash.isnil';
    import * as flatten from 'lodash.flatten';

    const ALL_OPERATORS: string[] = [null, '.', '.is--'];
    const ALL_CONCEPTS: string[] = ['', ' ', RESERVED_CONCEPT, RESERVED_CONCEPT_TYPE, RESERVED_DOMAIN, RESERVED_DRILL_UP, 'company', 'english_speaking', 'company_scale', 'name', 'anno', 'lines_of_code', 'region', 'country', 'latitude', 'longitude', 'full_name_changed', 'project', 'domain', 'additional_column', 'meeting_style', 'popular_appeal', 'methodology'];
    const ALL_ENTITY_SETS_AND_DOMAINS: string[] = ['company', 'english_speaking', 'company_scale', 'region', 'project'];

    export const initData = {};
    export const testsDescriptors = ALL_ENTITY_SETS_AND_DOMAINS.reduce((acc, entitySetOrDomain: string) => {
      const BINARY_OPERATORS = [...flatMap(ALL_CONCEPTS, (parent: string) => map(ALL_CONCEPTS, (child) => [parent, child]))];
      const UNARY_OPERATORS = [...ALL_CONCEPTS];

      const description = `Autogenerated tests for ${entitySetOrDomain}`;

      acc[description] = flatten(
        ALL_OPERATORS.map((operator: string) => {
          const CONCEPTS_CLAUSE: any[] = isNil(operator) ? UNARY_OPERATORS : map([...BINARY_OPERATORS], (args: string[]) => args.join(operator));

          return CONCEPTS_CLAUSE.map((clause: string) => ({
            itTitle: `should be fine for ${clause}`,
            query: {
              repositoryPath: BASE_PATH + WS_TESTING_PATH + '/master-HEAD',
              dataset: WS_TESTING_PATH,
              from: 'entities',
              select: {key: [entitySetOrDomain]},
              where: {
                [clause]: true
              }
            }
          }));
        })
      );

      return acc;
    }, {});