Skip to content

Commit 9d10903

Browse files
committed
test: reset id count before each test
1 parent 1d61e25 commit 9d10903

File tree

4 files changed

+47
-15
lines changed

4 files changed

+47
-15
lines changed

packages/pluggableWidgets/datagrid-number-filter-web/src/components/__tests__/DatagridNumberFilter.spec.tsx

+19-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { createContext, createElement } from "react";
1616
import DatagridNumberFilter from "../../DatagridNumberFilter";
1717
import { Big } from "big.js";
1818
import { DatagridNumberFilterContainerProps } from "../../../typings/DatagridNumberFilterProps";
19+
import { resetIdCounter } from "downshift";
1920

2021
export interface StaticInfo {
2122
name: string;
@@ -39,6 +40,15 @@ const headerFilterStoreInfo: StaticInfo = {
3940

4041
jest.useFakeTimers();
4142

43+
beforeEach(() => {
44+
jest.spyOn(console, "warn").mockImplementation(() => {
45+
// noop
46+
});
47+
resetIdCounter();
48+
});
49+
50+
afterEach(() => (console.warn as jest.Mock).mockRestore());
51+
4252
describe("Number Filter", () => {
4353
describe("with single instance", () => {
4454
afterEach(() => {
@@ -189,7 +199,9 @@ describe("Number Filter", () => {
189199
.withType("Long")
190200
.withFormatter(
191201
value => value,
192-
() => {}
202+
() => {
203+
// noop
204+
}
193205
)
194206
.withFilterable(true)
195207
.build()
@@ -200,7 +212,9 @@ describe("Number Filter", () => {
200212
.withType("Decimal")
201213
.withFormatter(
202214
value => value,
203-
() => {}
215+
() => {
216+
// noop
217+
}
204218
)
205219
.withFilterable(true)
206220
.build()
@@ -360,7 +374,9 @@ describe("Number Filter", () => {
360374
.withType("Long")
361375
.withFormatter(
362376
value => value,
363-
() => {}
377+
() => {
378+
// noop
379+
}
364380
)
365381
.withFilterable(true)
366382
.build()

packages/pluggableWidgets/datagrid-number-filter-web/src/components/__tests__/__snapshots__/DatagridNumberFilter.spec.tsx.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ exports[`Number Filter with single instance with multiple attributes renders cor
1414
>
1515
<button
1616
aria-activedescendant=""
17-
aria-controls="downshift-:r5:-menu"
17+
aria-controls="downshift-:r7:-menu"
1818
aria-expanded="false"
1919
aria-haspopup="listbox"
2020
aria-label="Equal"
2121
class="btn btn-default filter-selector-button button-icon equal"
22-
id="downshift-:r5:-toggle-button"
22+
id="downshift-:r7:-toggle-button"
2323
role="combobox"
2424
tabindex="0"
2525
>
@@ -28,7 +28,7 @@ exports[`Number Filter with single instance with multiple attributes renders cor
2828
<ul
2929
aria-label="Select filter type"
3030
class="filter-selectors hidden"
31-
id="downshift-:r5:-menu"
31+
id="downshift-:r7:-menu"
3232
role="listbox"
3333
style="position: fixed; left: 0px; top: 0px; transform: translate(0px, 0px);"
3434
/>

packages/pluggableWidgets/datagrid-text-filter-web/src/components/__tests__/DatagridTextFilter.spec.tsx

+19-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import userEvent from "@testing-library/user-event";
1313
import { createContext, createElement } from "react";
1414
import DatagridTextFilter from "../../DatagridTextFilter";
1515
import { DatagridTextFilterContainerProps } from "../../../typings/DatagridTextFilterProps";
16+
import { resetIdCounter } from "downshift";
1617

1718
export interface StaticInfo {
1819
name: string;
@@ -36,6 +37,15 @@ const headerFilterStoreInfo: StaticInfo = {
3637

3738
jest.useFakeTimers();
3839

40+
beforeEach(() => {
41+
jest.spyOn(console, "warn").mockImplementation(() => {
42+
// noop
43+
});
44+
resetIdCounter();
45+
});
46+
47+
afterEach(() => (console.warn as jest.Mock).mockRestore());
48+
3949
describe("Text Filter", () => {
4050
describe("with single instance", () => {
4151
afterEach(() => {
@@ -251,7 +261,9 @@ describe("Text Filter", () => {
251261
.withType("String")
252262
.withFormatter(
253263
value => value,
254-
() => {}
264+
() => {
265+
//
266+
}
255267
)
256268
.withFilterable(true)
257269
.build()
@@ -262,7 +274,9 @@ describe("Text Filter", () => {
262274
.withType("HashString")
263275
.withFormatter(
264276
value => value,
265-
() => {}
277+
() => {
278+
//
279+
}
266280
)
267281
.withFilterable(true)
268282
.build()
@@ -369,7 +383,9 @@ describe("Text Filter", () => {
369383
.withType("String")
370384
.withFormatter(
371385
value => value,
372-
() => {}
386+
() => {
387+
//
388+
}
373389
)
374390
.withFilterable(true)
375391
.build()

packages/pluggableWidgets/datagrid-text-filter-web/src/components/__tests__/__snapshots__/DatagridTextFilter.spec.tsx.snap

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ exports[`Text Filter with single instance with multiple attributes renders corre
1414
>
1515
<button
1616
aria-activedescendant=""
17-
aria-controls="downshift-:r5:-menu"
17+
aria-controls="downshift-:r8:-menu"
1818
aria-expanded="false"
1919
aria-haspopup="listbox"
2020
aria-label="Equal"
2121
class="btn btn-default filter-selector-button button-icon equal"
22-
id="downshift-:r5:-toggle-button"
22+
id="downshift-:r8:-toggle-button"
2323
role="combobox"
2424
tabindex="0"
2525
>
@@ -28,7 +28,7 @@ exports[`Text Filter with single instance with multiple attributes renders corre
2828
<ul
2929
aria-label="Select filter type"
3030
class="filter-selectors hidden"
31-
id="downshift-:r5:-menu"
31+
id="downshift-:r8:-menu"
3232
role="listbox"
3333
style="position: fixed; left: 0px; top: 0px; transform: translate(0px, 0px);"
3434
/>
@@ -67,12 +67,12 @@ exports[`Text Filter with single instance with single attribute renders correctl
6767
>
6868
<button
6969
aria-activedescendant=""
70-
aria-controls="downshift-:r3:-menu"
70+
aria-controls="downshift-:r5:-menu"
7171
aria-expanded="false"
7272
aria-haspopup="listbox"
7373
aria-label="Equal"
7474
class="btn btn-default filter-selector-button button-icon equal"
75-
id="downshift-:r3:-toggle-button"
75+
id="downshift-:r5:-toggle-button"
7676
role="combobox"
7777
tabindex="0"
7878
>
@@ -81,7 +81,7 @@ exports[`Text Filter with single instance with single attribute renders correctl
8181
<ul
8282
aria-label="Select filter type"
8383
class="filter-selectors hidden"
84-
id="downshift-:r3:-menu"
84+
id="downshift-:r5:-menu"
8585
role="listbox"
8686
style="position: fixed; left: 0px; top: 0px; transform: translate(0px, 0px);"
8787
/>

0 commit comments

Comments
 (0)