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
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: styfle/cancel-workflow-action@0.9.1
with:
all_but_latest: true
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Dependencies
Expand All @@ -34,10 +34,10 @@ jobs:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 18.x
cache: yarn

- name: Install dependencies
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ jobs:
- uses: styfle/cancel-workflow-action@0.9.1
with:
all_but_latest: true
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v4
name: Yarn Cache
id: yarn-cache
with:
Expand All @@ -53,7 +53,7 @@ jobs:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
report-json: 'eslint-report.json'
- name: Upload ESLint report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: eslint-report.json
path: eslint-report.json
Expand All @@ -66,16 +66,16 @@ jobs:
- uses: styfle/cancel-workflow-action@0.9.1
with:
all_but_latest: true
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v4
name: Yarn Cache
id: yarn-cache
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
- name: Yarn Install
uses: nick-invision/retry@v1
with:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/tests_e2e_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ jobs:
with:
all_but_latest: true

- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 50

# Set up tool versions
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'

- name: Configure JDK 1.11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
Expand All @@ -54,7 +54,7 @@ jobs:
echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
echo "::set-output name=tempdir::$TMPDIR"

- uses: actions/cache@v2
- uses: actions/cache@v4
name: Yarn Cache
id: yarn-cache
with:
Expand All @@ -70,7 +70,7 @@ jobs:
max_attempts: 3
command: DETOX_DISABLE_POSTINSTALL=1 yarn --no-audit --prefer-offline && cd example && yarn --no-audit --prefer-offline

- uses: actions/cache@v2
- uses: actions/cache@v4
name: Gradle Cache
with:
path: ~/.gradle/caches
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
shell: bash

- name: Upload Emulator Log
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: adb_logs
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/tests_e2e_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
all_but_latest: true

# Set up tool versions
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18

- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 50

Expand All @@ -51,15 +51,15 @@ jobs:
echo "::set-output name=xcode-version::$(xcodebuild -version|tail -1|cut -f3 -d' ')"
echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"

- uses: actions/cache@v2
- uses: actions/cache@v4
name: Yarn Cache
id: yarn-cache
with:
path: ${{ steps.workflow-variables.outputs.yarn-cache-dir }}
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/package.json') }}
restore-keys: ${{ runner.os }}-yarn-v1

- uses: actions/cache@v2
- uses: actions/cache@v4
name: Detox Framework Cache
id: detox-cache
with:
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
max_attempts: 3
command: gem update cocoapods xcodeproj

- uses: actions/cache@v2
- uses: actions/cache@v4
name: Cache Pods
id: pods-cache
with:
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
run: gzip -9 simulator.log

- name: Upload Simulator Log
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: simulator_log
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests_jest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ jobs:
- uses: styfle/cancel-workflow-action@0.9.1
with:
all_but_latest: true
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 50
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v4
name: Yarn Cache
id: yarn-cache
with:
Expand Down
1 change: 1 addition & 0 deletions android/progaurd-rules.pro
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
-keep class com.amazon.device.ads.** { *; }
-keep class com.adversport.rnaps.** { *; }
56 changes: 41 additions & 15 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,43 @@
import * as ReactNative from 'react-native';
// Jest setup for React Native library testing

jest.mock(
'./node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter'
);

jest.doMock('react-native', () => {
return Object.setPrototypeOf(
{
Platform: {
OS: 'android',
select: () => {},
},
// Mock only performance object to fix Jest + React Native conflict
if (!(global as any).performance) {
Object.defineProperty(global, 'performance', {
writable: true,
enumerable: true,
configurable: true,
value: {
now: () => Date.now(),
mark: () => {},
measure: () => {},
},
ReactNative
);
});
});
}

// Minimal React Native mock - let individual tests override as needed
// Create a shared event emitter instance for all tests
const listeners = new Map<string, any[]>();

const mockEventEmitter = {
addListener: jest.fn((eventName: string, listener: any) => {
if (!listeners.has(eventName)) {
listeners.set(eventName, []);
}
listeners.get(eventName)!.push(listener);
return { remove: jest.fn() };
}),
removeAllListeners: jest.fn(),
emit: jest.fn((eventName: string, payload: any) => {
const eventListeners = listeners.get(eventName) || [];
eventListeners.forEach((listener: any) => listener(payload));
}),
};

jest.mock('react-native', () => ({
Platform: {
OS: 'android',
select: jest.fn(),
},
NativeEventEmitter: jest.fn(() => mockEventEmitter),
NativeModules: {},
}));
31 changes: 29 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"main": "lib/commonjs/index",
"module": "lib/module/index",
"types": "lib/typescript/index.d.ts",
"react-native": "src/index",
"source": "src/index",
"files": [
"/android/",
Expand Down Expand Up @@ -113,13 +112,30 @@
"registry": "https://registry.npmjs.org/"
},
"jest": {
"preset": "react-native",
"testEnvironment": "node",
"modulePathIgnorePatterns": [
"<rootDir>/Example/node_modules",
"<rootDir>/lib/"
],
"setupFiles": [
"./jest.setup.ts"
],
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
},
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
],
"testMatch": [
"**/__tests__/**/*.(ts|tsx|js)"
],
"collectCoverageFrom": [
"src/**/*.{ts,tsx}",
"!src/**/*.d.ts"
]
},
"detox": {
Expand Down Expand Up @@ -260,5 +276,16 @@
"name": "rnaps",
"type": "modules",
"jsSrcsDir": "./src/turbomodules"
},
"react-native": {
"main": "src/index",
"android": {
"sourceDir": "./android/",
"packageImportPath": "import com.adversport.rnaps.RNAPSPackage;",
"packageInstance": "new RNAPSPackage()"
},
"ios": {
"podspecPath": "./RNAmazonPublisherServices.podspec"
}
}
}
2 changes: 1 addition & 1 deletion src/types/AdNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export enum AdNetwork {
MAX = 'MAX',
NIMBUS = 'NIMBUS',
OTHER = 'OTHER',
};
}

export function isAdNetwork(value: any): value is AdNetwork {
return Object.values(AdNetwork).includes(value);
Expand Down
2 changes: 1 addition & 1 deletion src/types/MRAIDPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export enum MRAIDPolicy {
NONE = 'NONE',
DFP = 'DFP',
CUSTOM = 'CUSTOM',
};
}

export function isMRAIDPolicy(value: any): value is MRAIDPolicy {
return Object.values(MRAIDPolicy).includes(value);
Expand Down
Loading