-
Benachrichtigungen
You must be signed in to change notification settings - Fork 4
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
Showing
4 changed files
with
53 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { SDKAnalyticsConstants } from '../internal/SDKAnalyticsConstants'; | ||
import { Platform, Image } from 'react-native'; | ||
import AdvancedImage from '../AdvancedImage'; | ||
import { CloudinaryImage } from '@cloudinary/url-gen/assets/CloudinaryImage'; | ||
import { render } from '@testing-library/react-native'; | ||
import React from 'react'; | ||
|
||
const cloudinaryImage = new CloudinaryImage('sample', { cloudName: 'demo' }); | ||
|
||
describe('analytics', () => { | ||
beforeEach(() => { | ||
SDKAnalyticsConstants.sdkSemver = '1.0.0'; | ||
SDKAnalyticsConstants.techVersion = '10.2.5'; | ||
}); | ||
it('creates a url with analytics', () => { | ||
const element = render(<AdvancedImage cldImg={cloudinaryImage}></AdvancedImage>); | ||
const imageComponent = element.root.findByType(Image); | ||
expect(imageComponent.props.source.uri).toBe(cloudinaryImage.toURL({trackedAnalytics: SDKAnalyticsConstants})); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Platform } from 'react-native'; | ||
|
||
const getReactNativeVersion = () => { | ||
try{ | ||
const version = Platform.Version; | ||
return version.toString(); | ||
} catch { | ||
return "0.0.0" | ||
} | ||
} | ||
|
||
const getSDKVersion = () => { | ||
try{ | ||
const SDKVersionPackageJson = require('cloudinary-react-native/package.json') | ||
if (SDKVersionPackageJson && SDKVersionPackageJson.version) { | ||
//return SDKVersionPackageJson.version | ||
return | ||
} | ||
} catch { | ||
return "0.0.0"; | ||
} | ||
return "0.0.0"; | ||
} | ||
|
||
export const SDKAnalyticsConstants = { | ||
sdkSemver: getSDKVersion(), | ||
techVersion: getReactNativeVersion(), | ||
sdkCode: 'P' | ||
}; |