This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace [`axios`](ttps://github.com/axios/axios) with raw [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) API to talk to smuggler from web (web app, browser extension, etc). Basically `axios` doesn't work in chrome extension, `axios` GitHub issue axios/axios#2968 - [x] Replace `axios` with `fetch` - [x] Replaced `axios`'s `CancelToken` with `fetch`'s `AbortControler` all over the truthsayer code - [x] Separated `archaeologist` build in development and production modes - to use different endpoints of smuggler - [x] Added simple `ping` from archaeologist background code to test that smuggler API actually works for it - [x] Added special environment variables for archaeologist to distinguish different bowsers in TS/JS code (not used yet) - [x] Fixed a problem with cross origin permissions in `archaeologist` by adding `host_permissions` to `manifest.json`
- Loading branch information
1 parent
213f19f
commit 667cc0b
Showing
45 changed files
with
739 additions
and
609 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
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
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
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
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
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,37 @@ | ||
import { makeUrl } from './api' | ||
|
||
describe('test suite for makeUrl', () => { | ||
const SAVED_ENV = process.env | ||
|
||
beforeEach(() => { | ||
process.env = { ...SAVED_ENV } // Make a copy | ||
}) | ||
|
||
afterAll(() => { | ||
process.env = SAVED_ENV // Restore old environment | ||
}) | ||
|
||
test('API_URL is undefined', () => { | ||
expect(makeUrl()).toStrictEqual('/') | ||
}) | ||
|
||
test('API_URL is absolute url', () => { | ||
const apiUrl = 'https://abc.mazed.dev' | ||
process.env.REACT_APP_SMUGGLER_API_URL = apiUrl | ||
expect(makeUrl()).toStrictEqual(`${apiUrl}/`) | ||
expect(makeUrl('node')).toStrictEqual(`${apiUrl}/node`) | ||
expect(makeUrl('node/')).toStrictEqual(`${apiUrl}/node`) | ||
expect(makeUrl('/node/')).toStrictEqual(`${apiUrl}/node`) | ||
expect(makeUrl('node/abc')).toStrictEqual(`${apiUrl}/node/abc`) | ||
expect(makeUrl('node/abc', { abc: 12 })).toStrictEqual( | ||
`${apiUrl}/node/abc?abc=12` | ||
) | ||
}) | ||
|
||
test('API_URL is local path', () => { | ||
const apiUrl = '/abc/dev' | ||
process.env.REACT_APP_SMUGGLER_API_URL = apiUrl | ||
expect(makeUrl()).toStrictEqual(`${apiUrl}/`) | ||
expect(makeUrl('node')).toStrictEqual(`${apiUrl}/node`) | ||
}) | ||
}) |
Oops, something went wrong.