Skip to content

Commit

Permalink
test: 💍 ammend tests following tag view bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskaransarkaria committed Nov 25, 2021
1 parent d45ff01 commit 8612b56
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .routify/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ module.exports = {
noHashScroll: false,
distDir: 'dist',
extensions: ['svelte', 'html', 'svx', 'md'],
started: '2021-11-24T19:14:39.743Z',
started: '2021-11-25T19:05:29.616Z',
};
4 changes: 2 additions & 2 deletions .routify/routes.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @roxi/routify 2.7.3
* File generated Wed Nov 24 2021 19:14:42 GMT+0000 (Greenwich Mean Time)
* File generated Thu Nov 25 2021 19:05:33 GMT+0000 (Greenwich Mean Time)
*/

export const __version = '2.7.3';
export const __timestamp = '2021-11-24T19:14:42.752Z';
export const __timestamp = '2021-11-25T19:05:33.824Z';

//buildRoutes
import { buildClientTree } from '@roxi/routify/runtime/buildRoutes';
Expand Down
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="stylesheet" href="/global.css" />
<link rel="stylesheet" href="/build/bundle-1637781279741.css" />
<link rel="stylesheet" href="/build/bundle-1637867129614.css" />

<script defer src="/build/bundle-1637781279741.js"></script>
<script defer src="/build/bundle-1637867129614.js"></script>
</head>
<body></body>
</html>
7 changes: 4 additions & 3 deletions src/components/HexGrid/HexGrid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
export let data: Base[] = [];
export let categoryFn: BaseFn;
const createEmptyArray = () => new Array(data.length).fill(undefined);
const createEmptyArray = (length: number) =>
new Array(length).fill(undefined);
let imgElemArr: HTMLImageElement[] = [...createEmptyArray()];
let sourceElemArr: HTMLSourceElement[] = [...createEmptyArray()];
let imgElemArr: HTMLImageElement[] = [...createEmptyArray(data.length)];
let sourceElemArr: HTMLSourceElement[] = [...createEmptyArray(data.length)];
const handleError = (idx: number) => {
imgElemArr[idx].onerror = null;
Expand Down
2 changes: 1 addition & 1 deletion src/components/TagView/TagView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
};
</script>

<HexGrid data={[...tags, ...data]} categoryFn={selectFn} />
<HexGrid data={[...data, ...tags]} categoryFn={selectFn} />
10 changes: 5 additions & 5 deletions src/components/TagView/TagView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ describe('Given TagView', () => {
'hex-category-name'
);
expect(allDisplayedCats).toHaveLength(2);
expect(allDisplayedCats[0]).toHaveTextContent('Zebra');
expect(allDisplayedCats[1]).toHaveTextContent('Elephant');
expect(allDisplayedCats[0]).toHaveTextContent('Elephant');
expect(allDisplayedCats[1]).toHaveTextContent('Zebra');
});

it('AND a non tag category is clicked THEN fire the categoryFn', async () => {
Expand Down Expand Up @@ -100,12 +100,12 @@ describe('Given TagView', () => {
);

expect(allDisplayedCats).toHaveLength(2);
expect(allDisplayedCats[0]).toHaveTextContent('Buffalo');
expect(allDisplayedCats[1]).toHaveTextContent('Elephant');
expect(allDisplayedCats[0]).toHaveTextContent('Elephant');
expect(allDisplayedCats[1]).toHaveTextContent('Buffalo');

const allButtons = await screen.queryAllByTestId('hex-button');

userEvent.click(allButtons[1]);
userEvent.click(allButtons[0]);
expect(mockFn).toHaveBeenCalledTimes(1);
});

Expand Down

0 comments on commit 8612b56

Please sign in to comment.