refactor: improve build configuration and code organization
- Add build scripts for Android and iOS platforms - Remove duplicate web implementation (src/web.ts) - Add proper TypeScript configuration - Add module documentation to index.ts - Clean up package.json scripts This commit improves the project structure and build process by: 1. Adding dedicated build scripts for native platforms 2. Removing redundant web implementation 3. Adding proper TypeScript configuration with strict mode 4. Improving code documentation 5. Organizing package.json scripts The changes maintain backward compatibility while improving the development experience and code quality.
This commit is contained in:
50
tests/setup.ts
Normal file
50
tests/setup.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Test setup file for the Daily Notification plugin
|
||||
*/
|
||||
|
||||
import { jest, afterEach } from '@jest/globals';
|
||||
|
||||
// Mock Capacitor plugin
|
||||
jest.mock('@capacitor/core', () => ({
|
||||
Capacitor: {
|
||||
isNativePlatform: () => false,
|
||||
getPlatform: () => 'web',
|
||||
},
|
||||
WebPlugin: class {
|
||||
constructor() {
|
||||
return {
|
||||
addListener: jest.fn(),
|
||||
removeAllListeners: jest.fn(),
|
||||
};
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock Response
|
||||
const mockResponse = {
|
||||
ok: true,
|
||||
status: 200,
|
||||
json: jest.fn(),
|
||||
text: jest.fn(),
|
||||
blob: jest.fn(),
|
||||
arrayBuffer: jest.fn(),
|
||||
clone: jest.fn(),
|
||||
headers: new Headers(),
|
||||
redirected: false,
|
||||
statusText: 'OK',
|
||||
type: 'default',
|
||||
url: '',
|
||||
};
|
||||
|
||||
global.Response = jest.fn().mockImplementation(() => mockResponse) as unknown as typeof Response;
|
||||
|
||||
// Mock Date
|
||||
global.Date = jest.fn().mockImplementation(() => ({
|
||||
getTime: () => 0,
|
||||
toISOString: () => '2024-01-01T00:00:00.000Z',
|
||||
})) as unknown as typeof Date;
|
||||
|
||||
// Clean up mocks after each test
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
Reference in New Issue
Block a user