Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adding vitest and initial tagging function [TOL-909] #5

Merged
merged 5 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"start": "vite build --watch",
"build": "tsc && vite build",
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx",
"test:ci": "true",
"test": "vitest",
"test:ci": "vitest run",
"coverage": "vitest run --coverage",
"prepare": "husky install",
"presemantic-release": "yarn build",
"semantic-release": "semantic-release"
Expand All @@ -46,7 +48,8 @@
"react-dom": "^18.2.0",
"semantic-release": "^19.0.2",
"typescript": "^4.9.3",
"vite": "^4.1.0"
"vite": "^4.1.0",
"vitest": "^0.28.5"
},
"peerDependencies": {
"react": "^18.2.0",
Expand Down
21 changes: 21 additions & 0 deletions src/features/tagging/getLivePreviewProps.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { describe, it, expect } from 'vitest';
import { getLivePreviewProps } from './getLivePreviewProps';

describe('getLivePreviewProps', () => {
it('returns the expected props with a given entryId, fieldId and locale', () => {
const entryId = 'test-entry-id';
const fieldId = 'test-field-id';
const locale = 'test-locale';

const result = getLivePreviewProps({
entryId,
fieldId,
locale,
});
expect(result).toStrictEqual({
'data-contentful-field-id': fieldId,
'data-contentful-entry-id': entryId,
'data-contentful-locale': locale,
});
});
});
13 changes: 13 additions & 0 deletions src/features/tagging/getLivePreviewProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export type LivePreviewProps = {
fieldId: string | null | undefined;
entryId: string | null | undefined;
locale: string | null | undefined;
};

export const getLivePreviewProps = ({ fieldId, entryId, locale }: LivePreviewProps) => {
return {
'data-contentful-field-id': fieldId,
'data-contentful-entry-id': entryId,
'data-contentful-locale': locale,
};
};
2 changes: 2 additions & 0 deletions src/features/tagging/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { LivePreviewProps } from './getLivePreviewProps';
export { getLivePreviewProps } from './getLivePreviewProps';
4 changes: 1 addition & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export const testFunction = () => {
console.log('live preview package works!');
};
export * from './features/tagging';
Loading