Skip to content

Commit

Permalink
test: reset id count before each test
Browse files Browse the repository at this point in the history
  • Loading branch information
iobuhov committed Dec 4, 2024
1 parent 1d61e25 commit 9d10903
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { createContext, createElement } from "react";
import DatagridNumberFilter from "../../DatagridNumberFilter";
import { Big } from "big.js";
import { DatagridNumberFilterContainerProps } from "../../../typings/DatagridNumberFilterProps";
import { resetIdCounter } from "downshift";

export interface StaticInfo {
name: string;
Expand All @@ -39,6 +40,15 @@ const headerFilterStoreInfo: StaticInfo = {

jest.useFakeTimers();

beforeEach(() => {
jest.spyOn(console, "warn").mockImplementation(() => {
// noop
});
resetIdCounter();
});

afterEach(() => (console.warn as jest.Mock).mockRestore());

describe("Number Filter", () => {
describe("with single instance", () => {
afterEach(() => {
Expand Down Expand Up @@ -189,7 +199,9 @@ describe("Number Filter", () => {
.withType("Long")
.withFormatter(
value => value,
() => {}
() => {
// noop
}
)
.withFilterable(true)
.build()
Expand All @@ -200,7 +212,9 @@ describe("Number Filter", () => {
.withType("Decimal")
.withFormatter(
value => value,
() => {}
() => {
// noop
}
)
.withFilterable(true)
.build()
Expand Down Expand Up @@ -360,7 +374,9 @@ describe("Number Filter", () => {
.withType("Long")
.withFormatter(
value => value,
() => {}
() => {
// noop
}
)
.withFilterable(true)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ exports[`Number Filter with single instance with multiple attributes renders cor
>
<button
aria-activedescendant=""
aria-controls="downshift-:r5:-menu"
aria-controls="downshift-:r7:-menu"
aria-expanded="false"
aria-haspopup="listbox"
aria-label="Equal"
class="btn btn-default filter-selector-button button-icon equal"
id="downshift-:r5:-toggle-button"
id="downshift-:r7:-toggle-button"
role="combobox"
tabindex="0"
>
Expand All @@ -28,7 +28,7 @@ exports[`Number Filter with single instance with multiple attributes renders cor
<ul
aria-label="Select filter type"
class="filter-selectors hidden"
id="downshift-:r5:-menu"
id="downshift-:r7:-menu"
role="listbox"
style="position: fixed; left: 0px; top: 0px; transform: translate(0px, 0px);"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import userEvent from "@testing-library/user-event";
import { createContext, createElement } from "react";
import DatagridTextFilter from "../../DatagridTextFilter";
import { DatagridTextFilterContainerProps } from "../../../typings/DatagridTextFilterProps";
import { resetIdCounter } from "downshift";

export interface StaticInfo {
name: string;
Expand All @@ -36,6 +37,15 @@ const headerFilterStoreInfo: StaticInfo = {

jest.useFakeTimers();

beforeEach(() => {
jest.spyOn(console, "warn").mockImplementation(() => {
// noop
});
resetIdCounter();
});

afterEach(() => (console.warn as jest.Mock).mockRestore());

describe("Text Filter", () => {
describe("with single instance", () => {
afterEach(() => {
Expand Down Expand Up @@ -251,7 +261,9 @@ describe("Text Filter", () => {
.withType("String")
.withFormatter(
value => value,
() => {}
() => {
//
}
)
.withFilterable(true)
.build()
Expand All @@ -262,7 +274,9 @@ describe("Text Filter", () => {
.withType("HashString")
.withFormatter(
value => value,
() => {}
() => {
//
}
)
.withFilterable(true)
.build()
Expand Down Expand Up @@ -369,7 +383,9 @@ describe("Text Filter", () => {
.withType("String")
.withFormatter(
value => value,
() => {}
() => {
//
}
)
.withFilterable(true)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ exports[`Text Filter with single instance with multiple attributes renders corre
>
<button
aria-activedescendant=""
aria-controls="downshift-:r5:-menu"
aria-controls="downshift-:r8:-menu"
aria-expanded="false"
aria-haspopup="listbox"
aria-label="Equal"
class="btn btn-default filter-selector-button button-icon equal"
id="downshift-:r5:-toggle-button"
id="downshift-:r8:-toggle-button"
role="combobox"
tabindex="0"
>
Expand All @@ -28,7 +28,7 @@ exports[`Text Filter with single instance with multiple attributes renders corre
<ul
aria-label="Select filter type"
class="filter-selectors hidden"
id="downshift-:r5:-menu"
id="downshift-:r8:-menu"
role="listbox"
style="position: fixed; left: 0px; top: 0px; transform: translate(0px, 0px);"
/>
Expand Down Expand Up @@ -67,12 +67,12 @@ exports[`Text Filter with single instance with single attribute renders correctl
>
<button
aria-activedescendant=""
aria-controls="downshift-:r3:-menu"
aria-controls="downshift-:r5:-menu"
aria-expanded="false"
aria-haspopup="listbox"
aria-label="Equal"
class="btn btn-default filter-selector-button button-icon equal"
id="downshift-:r3:-toggle-button"
id="downshift-:r5:-toggle-button"
role="combobox"
tabindex="0"
>
Expand All @@ -81,7 +81,7 @@ exports[`Text Filter with single instance with single attribute renders correctl
<ul
aria-label="Select filter type"
class="filter-selectors hidden"
id="downshift-:r3:-menu"
id="downshift-:r5:-menu"
role="listbox"
style="position: fixed; left: 0px; top: 0px; transform: translate(0px, 0px);"
/>
Expand Down

0 comments on commit 9d10903

Please sign in to comment.