-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
747935c
commit c8b36f4
Showing
5 changed files
with
45 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 14 additions & 20 deletions
34
packages/ts-components/src/components/social-embed/helpers/__tests__/getVendorTitle.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
import { getVendorTitle } from '../getVendorTitle'; | ||
import { socialMediaVendors } from '../socialMediaVendors'; | ||
|
||
describe('getVendorTitle', () => { | ||
const mockSocialMediaVendors = { | ||
facebook: 'FacebookID', | ||
instagram: 'InstagramID' | ||
}; | ||
|
||
it('should return "X (Twitter)" if the title is "twitter"', () => { | ||
const result = getVendorTitle('twitter', mockSocialMediaVendors); | ||
expect(result).toBe('X (Twitter)'); | ||
it('should return the correct title for twitter', () => { | ||
const title = getVendorTitle('twitter', socialMediaVendors); | ||
expect(title).toBe('X (Twitter)'); | ||
}); | ||
|
||
it('should return the id from socialMediaVendors if the title exists', () => { | ||
const result = getVendorTitle('facebook', mockSocialMediaVendors); | ||
expect(result).toBe('FacebookID'); | ||
it('should return the correct title for youtube', () => { | ||
const title = getVendorTitle('youtube', socialMediaVendors); | ||
expect(title).toBe('Youtube'); | ||
}); | ||
|
||
// it('should return the title if it does not exist in socialMediaVendors', () => { | ||
// const result = getVendorTitle('linkedin', mockSocialMediaVendors); | ||
// expect(result).toBe('linkedin'); | ||
// }); | ||
it('should return the correct title for tiktok', () => { | ||
const title = getVendorTitle('tiktok', socialMediaVendors); | ||
expect(title).toBe('Tiktok'); | ||
}); | ||
|
||
// it('should return the title if socialMediaVendors has no id for the given title', () => { | ||
// const mockVendorsWithoutId = { pinterest: {} }; | ||
// const result = getVendorTitle('pinterest', mockVendorsWithoutId); | ||
// expect(result).toBe('pinterest'); | ||
// }); | ||
it('should throw an error if the title does not exist in socialMediaVendors', () => { | ||
expect(() => getVendorTitle('nonexistent', socialMediaVendors)).toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 12 additions & 4 deletions
16
packages/ts-components/src/components/social-embed/helpers/socialMediaVendors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
export const socialMediaVendors: { | ||
[key: string]: { id: string; status: string }; | ||
[key: string]: { id: string; status: string; title: string }; | ||
} = { | ||
twitter: { id: '5fab0c31a22863611c5f8764', status: 'pending' }, | ||
youtube: { id: '5e7ac3fae30e7d1bc1ebf5e8', status: 'pending' }, | ||
tiktok: { id: '5e7f6927b8e05c4e491e7380', status: 'pending' } | ||
twitter: { | ||
id: '5fab0c31a22863611c5f8764', | ||
status: 'pending', | ||
title: 'X (Twitter)' | ||
}, | ||
youtube: { | ||
id: '5e7ac3fae30e7d1bc1ebf5e8', | ||
status: 'pending', | ||
title: 'Youtube' | ||
}, | ||
tiktok: { id: '5e7f6927b8e05c4e491e7380', status: 'pending', title: 'Tiktok' } | ||
}; |