Skip to content

Commit

Permalink
refactor: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackDark committed Nov 2, 2024
1 parent b6052e5 commit bcfa622
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ radarr: {}

test("should transform without error - quality_profiles instead of assign_scores_to", async () => {
const cloned = cloneWithJSON(config);
const instance = cloned.sonarr!["instance1"];
const { assign_scores_to, quality_profiles, ...rest } = instance.custom_formats![0];
const instance = cloned.sonarr!["instance1"]!;
const cF = instance.custom_formats![0];

instance.custom_formats![0] = { ...rest, quality_profiles: assign_scores_to ?? quality_profiles };
instance.custom_formats![0] = { ...cF, quality_profiles: cF?.assign_scores_to, assign_scores_to: undefined };

const transformed = transformConfig(config);
expect(transformed).not.toBeNull();
Expand Down
30 changes: 15 additions & 15 deletions src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ describe("SizeSpecification", async () => {

test("mismatch required", async () => {
const copied: typeof custom = JSON.parse(JSON.stringify(custom));
copied.specifications![0].required = true;
copied.specifications![0]!.required = true;

const result = compareCustomFormats(serverResponse, mapImportCfToRequestCf(toCarrCF(copied)));
expect(result.equal).toBe(false);
});

test("max differ", async () => {
const copied: typeof custom = JSON.parse(JSON.stringify(custom));
(copied.specifications![0].fields as TrashCFSpF).max = 100;
(copied.specifications![0]!.fields as TrashCFSpF).max = 100;

const result = compareCustomFormats(serverResponse, mapImportCfToRequestCf(toCarrCF(copied)));
expect(result.equal).toBe(false);
Expand Down Expand Up @@ -200,22 +200,22 @@ describe("compareImportCFs - general", async () => {
test("should not diff for fields length equal length", async () => {
const copied: typeof custom = JSON.parse(JSON.stringify(custom));
const clonedServer = cloneWithJSON(serverResponse);
clonedServer.specifications![0].fields = [clonedServer.specifications![0].fields![0]];
clonedServer.specifications![0]!.fields = [clonedServer.specifications![0]!.fields![0]!];

expect(clonedServer.specifications![0].fields.length).toBe(1);
expect(clonedServer.specifications![0]!.fields.length).toBe(1);

const result = compareCustomFormats(clonedServer, mapImportCfToRequestCf(toCarrCF(copied)));
expect(result.equal).toBe(true);
});

test("should diff for fields length if local is higher (should not happen normally)", async () => {
const copied: typeof custom = JSON.parse(JSON.stringify(custom));
copied.specifications![0].fields!.exceptLanguage = false;
copied.specifications![0]!.fields!.exceptLanguage = false;

const clonedServer = cloneWithJSON(serverResponse);
clonedServer.specifications![0].fields = [clonedServer.specifications![0].fields![0]];
clonedServer.specifications![0]!.fields = [clonedServer.specifications![0]!.fields![0]!];

expect(clonedServer.specifications![0].fields.length).toBe(1);
expect(clonedServer.specifications![0]!.fields.length).toBe(1);

const result = compareCustomFormats(clonedServer, mapImportCfToRequestCf(toCarrCF(copied)));
expect(result.equal).toBe(false);
Expand All @@ -224,10 +224,10 @@ describe("compareImportCFs - general", async () => {
test("should diff for specifications length bigger on remote", async () => {
const copied: typeof custom = JSON.parse(JSON.stringify(custom));
const clonedServer = cloneWithJSON(serverResponse);
clonedServer.specifications![0].fields = [clonedServer.specifications![0].fields![0]];
clonedServer.specifications?.push(clonedServer.specifications![0]);
clonedServer.specifications![0]!.fields = [clonedServer.specifications![0]!.fields![0]!];
clonedServer.specifications?.push(clonedServer.specifications![0]!);

expect(clonedServer.specifications![0].fields.length).toBe(1);
expect(clonedServer.specifications![0]!.fields.length).toBe(1);

const result = compareCustomFormats(clonedServer, mapImportCfToRequestCf(toCarrCF(copied)));
expect(result.equal).toBe(false);
Expand All @@ -236,10 +236,10 @@ describe("compareImportCFs - general", async () => {
test("should diff for specifications length smaller on remote", async () => {
const copied: typeof custom = JSON.parse(JSON.stringify(custom));
const clonedServer = cloneWithJSON(serverResponse);
clonedServer.specifications![0].fields = [clonedServer.specifications![0].fields![0]];
copied.specifications?.push(copied.specifications[0]);
clonedServer.specifications![0]!.fields = [clonedServer.specifications![0]!.fields![0]!];
copied.specifications?.push(copied.specifications[0]!);

expect(clonedServer.specifications![0].fields.length).toBe(1);
expect(clonedServer.specifications![0]!.fields.length).toBe(1);

const result = compareCustomFormats(clonedServer, mapImportCfToRequestCf(toCarrCF(copied)));
expect(result.equal).toBe(false);
Expand All @@ -248,9 +248,9 @@ describe("compareImportCFs - general", async () => {
test("should not diff for specifications length equal", async () => {
const copied: typeof custom = JSON.parse(JSON.stringify(custom));
const clonedServer = cloneWithJSON(serverResponse);
clonedServer.specifications![0].fields = [clonedServer.specifications![0].fields![0]];
clonedServer.specifications![0]!.fields = [clonedServer.specifications![0]!.fields![0]!];

expect(clonedServer.specifications![0].fields.length).toBe(1);
expect(clonedServer.specifications![0]!.fields.length).toBe(1);

const result = compareCustomFormats(clonedServer, mapImportCfToRequestCf(toCarrCF(copied)));
expect(result.equal).toBe(true);
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/demo-todo-app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { test, expect, type Page } from "@playwright/test";
import { expect, test, type Page } from "@playwright/test";

const TODO_ITEMS = ["buy some cheese", "feed the cat", "book a doctors appointment"] as const;

test.beforeEach(async ({ page }) => {
await page.goto("https://demo.playwright.dev/todomvc");
});

const TODO_ITEMS = ["buy some cheese", "feed the cat", "book a doctors appointment"];

test.describe("New Todo", () => {
test("should allow me to add todo items", async ({ page }) => {
// create a new todo locator
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
// breaks esbuild import
// "baseUrl": ".",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
Expand All @@ -17,7 +18,8 @@
"skipLibCheck": true,
"strict": true,
"strictNullChecks": true,
"target": "ESNext"
"target": "ESNext",
"noEmit": true
},
"exclude": ["./dist"],
"include": ["**/*.ts", "**/*.tsx"]
Expand Down

0 comments on commit bcfa622

Please sign in to comment.