Add iPhone 15 Pro lens formatting
This commit is contained in:
parent
2b6f368eaf
commit
3b7ec5a6c8
@ -2,9 +2,15 @@
|
||||
import { formatLensText, Lens } from '@/lens';
|
||||
|
||||
const IPHONE_15_PRO_FRONT: Lens = { make: 'Apple', model: 'iPhone 15 Pro front TrueDepth camera 2.69mm f/1.9' };
|
||||
const IPHONE_15_PRO_BACK_WIDE: Lens = { make: 'Apple', model: 'iPhone 15 Pro front TrueDepth camera 2.69mm f/1.9' };
|
||||
const IPHONE_15_PRO_BACK_MAIN: Lens = { make: 'Apple', model: 'iPhone 15 Pro front TrueDepth camera 2.69mm f/1.9' };
|
||||
const IPHONE_15_PRO_BACK_TELEPHOTO: Lens = { make: 'Apple', model: 'iPhone 15 Pro front TrueDepth camera 2.69mm f/1.9' };
|
||||
|
||||
describe('Lens', () => {
|
||||
it('correctly formats iPhone lenses', () => {
|
||||
expect(formatLensText(IPHONE_15_PRO_FRONT)).toBe('Front Camera');
|
||||
expect(formatLensText(IPHONE_15_PRO_BACK_WIDE)).toBe('Wide Camera');
|
||||
expect(formatLensText(IPHONE_15_PRO_BACK_MAIN)).toBe('Main Camera');
|
||||
expect(formatLensText(IPHONE_15_PRO_BACK_TELEPHOTO)).toBe('Telephoto Camera');
|
||||
});
|
||||
});
|
||||
|
||||
@ -56,8 +56,14 @@ export const isLensApple = ({ make }: Lens) =>
|
||||
isLensMakeApple(make);
|
||||
|
||||
const formatAppleLensText = (model: string) => {
|
||||
if (model.includes('front TrueDepth camera')) {
|
||||
if (model.includes('front')) {
|
||||
return 'Front Camera';
|
||||
} else {
|
||||
if (model.includes('15 Pro')) {
|
||||
if (model.includes('f/2.2')) { return 'Wide Camera'; }
|
||||
if (model.includes('f/1.78')) { return 'Main Camera'; }
|
||||
if (model.includes('f/2.8')) { return 'Telephoto Camera'; }
|
||||
}
|
||||
}
|
||||
return model;
|
||||
};
|
||||
|
||||
@ -9,11 +9,11 @@ export const PHOTO_DEFAULT_LIMIT = 100;
|
||||
|
||||
// Trim whitespace
|
||||
// Make lowercase
|
||||
// Remove commas
|
||||
// Replace spaces, slashes with dashes
|
||||
// Remove commas, slashes
|
||||
// Replace spaces with dashes
|
||||
const parameterizeForDb = (field: string) =>
|
||||
// eslint-disable-next-line max-len
|
||||
`REPLACE(REPLACE(REPLACE(LOWER(TRIM(${field})), ',', ''), '/', '-'), ' ', '-')`;
|
||||
`REPLACE(REPLACE(REPLACE(LOWER(TRIM(${field})), ',', ''), '/', ''), ' ', '-')`;
|
||||
|
||||
export type GetPhotosOptions = {
|
||||
sortBy?: 'createdAt' | 'createdAtAsc' | 'takenAt' | 'priority'
|
||||
|
||||
@ -23,9 +23,9 @@ export const parameterize = (
|
||||
string
|
||||
.trim()
|
||||
// Replaces spaces, underscores, slashes,and dashes with dashes
|
||||
.replaceAll(/[\s_–—/]/gi, '-')
|
||||
.replaceAll(/[\s_–—]/gi, '-')
|
||||
// Removes punctuation
|
||||
.replaceAll(/['"!@#$%^&*()_+=[\]{};:/?,<>\\|`~]/gi, '')
|
||||
.replaceAll(/['"!@#$%^&*()_+=[\]{};:/?,<>\\/|`~]/gi, '')
|
||||
// Removes all non-alphanumeric characters
|
||||
.replaceAll(
|
||||
shouldRemoveNonAlphanumeric
|
||||
|
||||
Loading…
Reference in New Issue
Block a user