setup mock browser object

This commit is contained in:
Vu Nguyen
2021-01-16 03:08:18 -06:00
parent 3839ad404b
commit 9ecc2144aa
9 changed files with 304 additions and 9 deletions

51
src/config.test.ts Normal file
View File

@@ -0,0 +1,51 @@
import config from './config';
describe('wakatime config', () => {
it('snapshot of config', () => {
expect(config).toMatchInlineSnapshot(`
Object {
"alert": Object {
"failure": Object {
"text": "There was an error while saving the options!",
"type": "danger",
},
"success": Object {
"text": "Options have been saved!",
"type": "success",
},
},
"colors": Object {
"allGood": "",
"lightTheme": "white",
"notLogging": "gray",
"notSignedIn": "red",
},
"currentUserApiUrl": "https://wakatime.com/api/v1/users/current",
"detectionIntervalInSeconds": 60,
"heartbeatApiUrl": "https://wakatime.com/api/v1/users/current/heartbeats",
"loggingEnabled": true,
"loggingStyle": "blacklist",
"loggingType": "domain",
"logoutUserUrl": "https://wakatime.com/logout",
"name": "WakaTime",
"states": Array [
"allGood",
"notLogging",
"notSignedIn",
"blacklisted",
"whitelisted",
],
"summariesApiUrl": "https://wakatime.com/api/v1/users/current/summaries",
"theme": "light",
"tooltips": Object {
"allGood": "",
"blacklisted": "This URL is blacklisted",
"notLogging": "Not logging",
"notSignedIn": "Not signed In",
"whitelisted": "This URL is not on your whitelist",
},
"version": "test-version",
}
`);
});
});

View File

@@ -113,11 +113,13 @@ const config: Config = {
notSignedIn: 'red',
},
currentUserApiUrl: 'https://wakatime.com/api/v1/users/current',
currentUserApiUrl:
process.env.CURRENT_USER_API_URL ?? 'https://wakatime.com/api/v1/users/current',
detectionIntervalInSeconds: 60,
heartbeatApiUrl: 'https://wakatime.com/api/v1/users/current/heartbeats',
heartbeatApiUrl:
process.env.HEART_BEAT_API_URL ?? 'https://wakatime.com/api/v1/users/current/heartbeats',
loggingEnabled: true,
@@ -125,13 +127,14 @@ const config: Config = {
loggingType: 'domain',
logoutUserUrl: 'https://wakatime.com/logout',
logoutUserUrl: process.env.LOGOUT_USER_URL ?? 'https://wakatime.com/logout',
name: 'WakaTime',
states: ['allGood', 'notLogging', 'notSignedIn', 'blacklisted', 'whitelisted'],
summariesApiUrl: 'https://wakatime.com/api/v1/users/current/summaries',
summariesApiUrl:
process.env.SUMMARIES_API_URL ?? 'https://wakatime.com/api/v1/users/current/summaries',
theme: 'light',

6
src/jest.config.ts Normal file
View File

@@ -0,0 +1,6 @@
import jestConfig from '../jest.config';
export default {
...jestConfig,
testEnvironment: 'node',
};