Skip to content
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
1 change: 1 addition & 0 deletions __mocks__/fast-text-encoding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions __mocks__/react-native-get-random-values.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
3 changes: 3 additions & 0 deletions lib/index.react_native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import { createHttpPollingDatafileManager } from './plugins/datafile_manager/rea
import { BrowserOdpManager } from './plugins/odp_manager/index.browser';
import * as commonExports from './common_exports';

import 'fast-text-encoding';
import 'react-native-get-random-values';

const logger = getLogger();
setLogHandler(loggerPlugin.createLogger());
setLogLevel(LogLevel.INFO);
Expand Down
25 changes: 17 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@react-native-community/netinfo": "^11.3.2",
"@react-native-async-storage/async-storage": "^1.2.0",
"@react-native-community/netinfo": "^5.9.10",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@types/chai": "^4.2.11",
Expand Down Expand Up @@ -162,14 +162,22 @@
"peerDependencies": {
"@babel/runtime": "^7.0.0",
"@react-native-async-storage/async-storage": "^1.2.0",
"@react-native-community/netinfo": "5.9.4"
"@react-native-community/netinfo": "^11.3.2",
"react-native-get-random-values": "^1.11.0",
"fast-text-encoding": "^1.0.6"
},
"peerDependenciesMeta": {
"@react-native-async-storage/async-storage": {
"optional": true
},
"@react-native-community/netinfo": {
"optional": true
},
"react-native-get-random-values": {
"optional": true
},
"fast-text-encoding": {
"optional": true
}
},
"publishConfig": {
Expand Down
21 changes: 12 additions & 9 deletions tests/index.react_native.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import optimizelyFactory from '../lib/index.react_native';
import configValidator from '../lib/utils/config_validator';
import eventProcessorConfigValidator from '../lib/utils/event_processor_config_validator';

jest.mock('react-native-get-random-values')
jest.mock('fast-text-encoding')

describe('javascript-sdk/react-native', () => {
beforeEach(() => {
jest.spyOn(optimizelyFactory.eventDispatcher, 'dispatchEvent');
Expand All @@ -45,10 +48,10 @@ describe('javascript-sdk/react-native', () => {
});

describe('createInstance', () => {
var fakeErrorHandler = { handleError: function() {} };
var fakeEventDispatcher = { dispatchEvent: function() {} };
const fakeErrorHandler = { handleError: function() {} };
const fakeEventDispatcher = { dispatchEvent: function() {} };
// @ts-ignore
var silentLogger;
let silentLogger;

beforeEach(() => {
// @ts-ignore
Expand All @@ -65,7 +68,7 @@ describe('javascript-sdk/react-native', () => {

it('should not throw if the provided config is not valid', () => {
expect(function() {
var optlyInstance = optimizelyFactory.createInstance({
const optlyInstance = optimizelyFactory.createInstance({
datafile: {},
// @ts-ignore
logger: silentLogger,
Expand All @@ -77,7 +80,7 @@ describe('javascript-sdk/react-native', () => {
});

it('should create an instance of optimizely', () => {
var optlyInstance = optimizelyFactory.createInstance({
const optlyInstance = optimizelyFactory.createInstance({
datafile: {},
errorHandler: fakeErrorHandler,
eventDispatcher: fakeEventDispatcher,
Expand All @@ -94,7 +97,7 @@ describe('javascript-sdk/react-native', () => {
});

it('should set the React Native JS client engine and javascript SDK version', () => {
var optlyInstance = optimizelyFactory.createInstance({
const optlyInstance = optimizelyFactory.createInstance({
datafile: {},
errorHandler: fakeErrorHandler,
eventDispatcher: fakeEventDispatcher,
Expand All @@ -111,7 +114,7 @@ describe('javascript-sdk/react-native', () => {
});

it('should allow passing of "react-sdk" as the clientEngine and convert it to "react-native-sdk"', () => {
var optlyInstance = optimizelyFactory.createInstance({
const optlyInstance = optimizelyFactory.createInstance({
clientEngine: 'react-sdk',
datafile: {},
errorHandler: fakeErrorHandler,
Expand Down Expand Up @@ -155,7 +158,7 @@ describe('javascript-sdk/react-native', () => {
});

it('should call logging.setLogHandler with the supplied logger', () => {
var fakeLogger = { log: function() {} };
const fakeLogger = { log: function() {} };
optimizelyFactory.createInstance({
datafile: testData.getTestProjectConfig(),
// @ts-ignore
Expand All @@ -168,7 +171,7 @@ describe('javascript-sdk/react-native', () => {

describe('event processor configuration', () => {
// @ts-ignore
var eventProcessorSpy;
let eventProcessorSpy;
beforeEach(() => {
eventProcessorSpy = jest.spyOn(eventProcessor, 'createEventProcessor');
});
Expand Down