Skip to content

Commit

Permalink
added anti-pinch meta
Browse files Browse the repository at this point in the history
  • Loading branch information
CropWatchDevelopment committed Oct 8, 2024
1 parent f9a69da commit 98e1865
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
1 change: 1 addition & 0 deletions setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom';
3 changes: 2 additions & 1 deletion src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<link rel="icon" sizes="196x196" href="%sveltekit.assets%/icons/apple-touch-icon.png" />
<link rel="manifest" href="%sveltekit.assets%/manifest.json" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="HandheldFriendly" content="true" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-wep-app-capable" content="yes" />
<meta name="google" content="notranslate">
Expand Down
71 changes: 71 additions & 0 deletions src/lib/components/ui/Sensors/SensorHeader.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// SensorStatus.test.ts

import { readable } from 'svelte/store';
import { render, screen } from '@testing-library/svelte';
import { describe, it, vi, beforeEach, afterEach } from 'vitest';

// Mock the svelte-i18n module
vi.mock('svelte-i18n', () => {
return { _: readable((key: string) => key) };
});

// Mock image imports
vi.mock('$lib/images/UI/cw-10.svg', () => ({
default: 'active-image-mock',
}));
vi.mock('$lib/images/UI/cw_sensor_status_inactive.svg', () => ({
default: 'inactive-image-mock',
}));

// Mock svelte-ux components
vi.mock('svelte-ux', () => ({
CopyButton: {},
Duration: {},
Tooltip: {},
}));

// Import the component under test after the mocks
import SensorHeader from './SensorHeader.svelte';

describe('SensorHeader component', () => {
beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2023-01-01T12:00:00Z'));
});

afterEach(() => {
vi.useRealTimers();
});

it('renders active status when isActiveRecently is true', () => {
const sensorName = 'Test Sensor';
const lastSeen = new Date('2023-01-01T11:55:00Z'); // 5 minutes ago
const upload_interval = 10; // 10 minutes

render(SensorHeader, {
props: {
sensorName,
lastSeen,
upload_interval,
},
});


});

it('renders inactive status when isActiveRecently is false', () => {
const sensorName = 'Test Sensor';
const lastSeen = new Date('2023-01-01T11:20:00Z'); // 40 minutes ago
const upload_interval = 10; // 10 minutes

render(SensorHeader, {
props: {
sensorName,
lastSeen,
upload_interval,
},
});


});
});

0 comments on commit 98e1865

Please sign in to comment.