|
1 | 1 | import { SDKAnalyticsConstants } from '../internal/SDKAnalyticsConstants'; |
2 | | -import { Image } from 'react-native'; |
| 2 | +import { Image, Platform } from 'react-native'; |
3 | 3 | import AdvancedImage from '../AdvancedImage'; |
4 | 4 | import { CloudinaryImage } from '@cloudinary/url-gen/assets/CloudinaryImage'; |
5 | 5 | import { render } from '@testing-library/react-native'; |
6 | 6 | import React from 'react'; |
7 | 7 |
|
8 | 8 | const cloudinaryImage = new CloudinaryImage('sample', { cloudName: 'demo' }); |
9 | 9 |
|
| 10 | + |
10 | 11 | describe('analytics', () => { |
11 | | - beforeEach(() => { |
12 | | - SDKAnalyticsConstants.sdkSemver = '1.0.0'; |
13 | | - SDKAnalyticsConstants.techVersion = '10.2.5'; |
14 | | - }); |
15 | | - it('creates a url with analytics', () => { |
16 | | - const element = render(<AdvancedImage cldImg={cloudinaryImage}></AdvancedImage>); |
17 | | - const imageComponent = element.root.findByType(Image); |
18 | | - expect(imageComponent.props.source.uri).toBe(cloudinaryImage.toURL({trackedAnalytics: SDKAnalyticsConstants})); |
19 | | - }); |
| 12 | + beforeEach(() => { |
| 13 | + SDKAnalyticsConstants.sdkSemver = '1.0.0'; |
| 14 | + SDKAnalyticsConstants.techVersion = '10.2.5'; |
| 15 | + SDKAnalyticsConstants.osType = 'A'; |
| 16 | + SDKAnalyticsConstants.osVersion = '30'; |
| 17 | + }); |
| 18 | + it('creates a url with analytics', () => { |
| 19 | + const element = render(<AdvancedImage cldImg={cloudinaryImage}></AdvancedImage>); |
| 20 | + const imageComponent = element.root.findByType(Image); |
| 21 | + expect(imageComponent.props.source.uri).toBe(cloudinaryImage.toURL({trackedAnalytics: SDKAnalyticsConstants})); |
| 22 | + }); |
| 23 | + |
| 24 | + it('sets correct osType', () => { |
| 25 | + expect(SDKAnalyticsConstants.osType).toBe('A'); // For Android |
| 26 | + }); |
| 27 | + |
| 28 | + it('sets correct osVersion', () => { |
| 29 | + expect(SDKAnalyticsConstants.osVersion).toBe('30'); // Mocked Android version (API level) |
20 | 30 | }); |
| 31 | +}); |
0 commit comments