Skip to content

Commit

Permalink
fix(packages/components): fix unit test (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicegginton authored Jun 4, 2024
1 parent a847c15 commit 74b44de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ describe('ArcAccessibility', () => {
describe('events', () => {
let element: ArcAccessibility;
let themeRadioGroup: ArcRadioGroup;
const accessibilityChangeHandler: SinonSpy = sinon.spy();
let accessibilityChangeHandler: SinonSpy;

/* Grab the user preferences from the localStore */
const getCachedPreferences = () => {
Expand All @@ -336,6 +336,7 @@ describe('ArcAccessibility', () => {
};

beforeEach(async () => {
accessibilityChangeHandler = sinon.spy();
element = await fixture(html`<arc-accessibility></arc-accessibility>`);
themeRadioGroup = element.shadowRoot?.getElementById(
'theme',
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/components/table/arc-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('ArcTable', () => {
/* Test specific methods */
describe('methods', () => {
let element: ArcTable;
const tableReadySpy: SinonSpy = sinon.spy();
let tableReadySpy: SinonSpy;

/* Due to GridJS creating the table, the reference to any DOM elements is lost after each update. */
const getTableBody = (): HTMLTableSectionElement => {
Expand All @@ -144,6 +144,7 @@ describe('ArcTable', () => {
};

beforeEach(async () => {
tableReadySpy = sinon.spy();
element = await fixture(html`<arc-table></arc-table>`);
element.addEventListener(ARC_EVENTS.tableReady, tableReadySpy);
});
Expand Down Expand Up @@ -214,8 +215,7 @@ describe('ArcTable', () => {
return columns[0] as HTMLTableCellElement;
};

/* Wait for the underlying GridJS instance to finish rendering. */
await waitUntil(() => tableReadySpy.calledOnce, 'Table did not render');
await waitUntil(() => tableReadySpy.calledOnce);

/* Update the GridJS configuration */
element.updateConfig({
Expand All @@ -229,7 +229,7 @@ describe('ArcTable', () => {
/* Wait for the underlying GridJS instance to finish rendering. */
await waitUntil(
() => tableReadySpy.calledTwice,
'Table did not update with date',
'Table did not update with data',
);

expect(firstColumn()).dom.to.equal('John');
Expand Down

0 comments on commit 74b44de

Please sign in to comment.