Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
fix(COR-1865): Update tests to work with new error mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-van-eekelen committed Dec 20, 2023
1 parent 22c0e25 commit 62c767b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import { getLastInsertionDateOfPage } from '../get-last-insertion-date-of-page';

const GetLastDateOfInsertion = suite('getLastInsertionDateOfPage');

GetLastDateOfInsertion('returns zero when data is empty', () => {
const result = getLastInsertionDateOfPage({}, ['key1']);
assert.is(result, 0);
GetLastDateOfInsertion('returns error when data is empty', () => {
assert.throws(() => getLastInsertionDateOfPage({}, ['key1']), /Pagemetrics not found in data/)
});

GetLastDateOfInsertion('returns zero when metrics are empty', () => {
const result = getLastInsertionDateOfPage(
{ key1: { last_value: { date_of_insertion_unix: 123 } } },
[]
);
assert.is(result, 0);
GetLastDateOfInsertion('returns error when metrics are empty', () => {
assert.throws(() => getLastInsertionDateOfPage(
{ key1: { last_value: { date_of_insertion_unix: 123 } } },
[]
), /Pagemetrics not found in data/);
});

GetLastDateOfInsertion('returns the max date_of_insertion_unix', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/utils/get-last-insertion-date-of-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function getLastInsertionDateOfPage(
pageMetrics: string[]
) {
const metricsAvailableInData: string[] = pageMetrics.filter((metricProperty) => {
return typeof get(data, metricProperty) === 'number';
return typeof get(data, metricProperty) !== 'undefined';
});

if (metricsAvailableInData.length === 0) {
Expand Down

0 comments on commit 62c767b

Please sign in to comment.