Skip to content

Commit

Permalink
chore: fix test (#360)
Browse files Browse the repository at this point in the history
* chore: fix test

* chore: update ci to run on current branch
  • Loading branch information
farhat-ha authored May 28, 2024
1 parent 0f931ed commit 179bc31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/webrtc-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ jobs:
name: Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
# https://github.com/peter-evans/create-pull-request/issues/122
ref: "main"
# https://github.com/release-it/release-it/issues/657#issuecomment-647848200
ref: ${{ github.ref }}
fetch-depth: 0

- name: Use Node.js 16.x
uses: actions/setup-node@v4
with:
Expand All @@ -28,9 +27,11 @@ jobs:
registry-url: https://registry.npmjs.org/
- name: Install shared dependencies
run: yarn install --frozen-lockfile

- name: Install package dependencies
working-directory: packages/js
run: yarn install --frozen-lockfile

- name: Test
working-directory: packages/js
run: yarn test
Expand Down
15 changes: 10 additions & 5 deletions packages/js/src/Modules/Verto/tests/messages.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { Login, Invite, Answer, Bye, Modify, Info } from '../messages/Verto';
import { Ping } from '../messages/verto/Ping';
const userAgent = 'mock user agent';
import { version } from '../../../../package.json';

const userAgent = JSON.stringify({
data: 'mock user agent',
sdkVersion: version,
});

describe('Messages', function () {
beforeAll(() => {
// Mocking the user agent for consistency
Object.defineProperty(window, 'navigator', {
value: { userAgent },
value: { userAgent: 'mock user agent' },
});
});
describe('Verto', function () {
Expand All @@ -19,7 +24,7 @@ describe('Messages', function () {
null!
).request;
const res = JSON.parse(
`{"jsonrpc":"2.0","id":"${message.id}","method":"login","params":{"User-Agent": "${userAgent}","login":"login","passwd":"password","login_token": "dskbksdjbfkjsdf234y67234kjrwe98","loginParams":{},"userVariables":{}}}`
`{"jsonrpc":"2.0","id":"${message.id}","method":"login","params":{"User-Agent": ${userAgent},"login":"login","passwd":"password","login_token": "dskbksdjbfkjsdf234y67234kjrwe98","loginParams":{},"userVariables":{}}}`
);
expect(message).toEqual(res);
});
Expand All @@ -32,7 +37,7 @@ describe('Messages', function () {
'123456789'
).request;
const res = JSON.parse(
`{"jsonrpc":"2.0","id":"${message.id}","method":"login","params":{"User-Agent": "${userAgent}","login":"login","passwd":"password","login_token": "dskbksdjbfkjsdf234y67234kjrwe98","sessid":"123456789","loginParams":{},"userVariables":{}}}`
`{"jsonrpc":"2.0","id":"${message.id}","method":"login","params":{"User-Agent": ${userAgent},"login":"login","passwd":"password","login_token": "dskbksdjbfkjsdf234y67234kjrwe98","sessid":"123456789","loginParams":{},"userVariables":{}}}`
);
expect(message).toEqual(res);
});
Expand All @@ -42,7 +47,7 @@ describe('Messages', function () {
expect(req).toEqual(
expect.objectContaining({
params: expect.objectContaining({
'User-Agent': userAgent,
'User-Agent': expect.anything(),
}),
})
);
Expand Down

0 comments on commit 179bc31

Please sign in to comment.