All files / publisher/listing/utils getDefaultData.ts

63.63% Statements 7/11
66.66% Branches 8/12
100% Functions 3/3
63.63% Lines 7/11

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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74          6x       6x           6x                 6x       6x             6x       6x                                                                    
import type { Data } from "../types";
 
function getPublicMetricsTerritoriesValue(
  publicMetricsBlacklist: string[],
): boolean {
  Iif (publicMetricsBlacklist.length === 0) {
    return true;
  }
 
  Eif (
    publicMetricsBlacklist.length === 1 &&
    publicMetricsBlacklist.includes(
      "weekly_installed_base_by_operating_system_normalized",
    )
  ) {
    return true;
  }
 
  return false;
}
 
function getPublicMetricsDistrosValue(
  publicMetricsBlacklist: string[],
): boolean {
  Iif (publicMetricsBlacklist.length === 0) {
    return true;
  }
 
  Iif (
    publicMetricsBlacklist.length === 1 &&
    publicMetricsBlacklist.includes("installed_base_by_country_percent")
  ) {
    return true;
  }
 
  return false;
}
 
export default function getDefaultData(data: Data): { [key: string]: any } {
  return {
    contacts: data.contacts,
    description: data.description,
    donations: data.donations,
    icon_url: data.icon_url,
    issues: data.issues,
    license: data.license,
    licenses: data.licenses,
    license_type: data.license_type,
    primary_category: data.primary_category,
    primary_website: data.primary_website,
    public_metrics_distros: getPublicMetricsDistrosValue(
      data.public_metrics_blacklist,
    ),
    public_metrics_enabled: data.public_metrics_enabled,
    public_metrics_territories: getPublicMetricsTerritoriesValue(
      data.public_metrics_blacklist,
    ),
    screenshots: [
      new File([], ""),
      new File([], ""),
      new File([], ""),
      new File([], ""),
      new File([], ""),
    ],
    screenshot_urls: data.screenshot_urls,
    secondary_category: data.secondary_category,
    source_code: data.source_code,
    summary: data.summary,
    title: data.title,
    video_urls: data.video_urls,
    websites: data.websites,
  };
}