From 0b43f5b9537746f12bee201dc926385b20973fbe Mon Sep 17 00:00:00 2001 From: Devin Moss Date: Mon, 3 Jul 2023 12:05:03 -0500 Subject: [PATCH] Jest config updates and dotenv --- jest.config.js | 1 + .../service/account-status-service.test.ts | 2 -- .../accounts-and-customers-service.test.ts | 10 +++---- .../balances-and-positions-service.test.ts | 2 -- .../service/instruments-service.test.ts | 2 -- .../margin-requirements-service.test.ts | 2 -- .../service/orders-service.test.ts | 30 +------------------ .../service/risk-parameters-service.test.ts | 2 -- .../service/session-service.test.ts | 2 -- .../service/symbol-search-service.test.ts | 2 -- .../service/transactions-service.test.ts | 20 ------------- .../service/watchlists-service.test.ts | 2 -- 12 files changed, 6 insertions(+), 71 deletions(-) diff --git a/jest.config.js b/jest.config.js index a08490a..55beec5 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,7 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { preset: 'ts-jest', + setupFiles: ["dotenv/config"], testEnvironment: 'node', transform: { '^.+\\.ts?$': 'ts-jest', diff --git a/tests/integration/service/account-status-service.test.ts b/tests/integration/service/account-status-service.test.ts index 6b54c9e..7372427 100644 --- a/tests/integration/service/account-status-service.test.ts +++ b/tests/integration/service/account-status-service.test.ts @@ -1,8 +1,6 @@ import AccountStatusService from "../../../lib/services/account-status-service"; import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client"; import SessionService from "../../../lib/services/session-service"; -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const accountStatusService = new AccountStatusService(client) diff --git a/tests/integration/service/accounts-and-customers-service.test.ts b/tests/integration/service/accounts-and-customers-service.test.ts index 9cb600b..5bff677 100644 --- a/tests/integration/service/accounts-and-customers-service.test.ts +++ b/tests/integration/service/accounts-and-customers-service.test.ts @@ -1,8 +1,6 @@ import AccountsAndCustomersService from "../../../lib/services/accounts-and-customers-service"; import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client"; import SessionService from "../../../lib/services/session-service"; -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const accountsAndCustomersService = new AccountsAndCustomersService(client) @@ -24,14 +22,14 @@ describe('getCustomerAccounts', () => { describe('getCustomerResource', () => { it('responds with the correct data', async function() { - const response = await accountsAndCustomersService.getCustomerResource(process.env.API_CUSTOMER_ID!) - expect(response.id).toBe(process.env.API_CUSTOMER_ID!) + const response = await accountsAndCustomersService.getCustomerResource('me') + expect(response.id).toBe('me') }) }) describe('getCustomerAccountResources', () => { it('responds with the correct data', async function() { - const response = await accountsAndCustomersService.getCustomerAccountResources(process.env.API_CUSTOMER_ID!) + const response = await accountsAndCustomersService.getCustomerAccountResources('me') expect(response.length).toBeGreaterThan(0) expect(response[0].account["account-number"]).toBeDefined(); expect(response[0].account["margin-or-cash"]).toBeDefined(); @@ -41,7 +39,7 @@ describe('getCustomerAccountResources', () => { describe('getFullCustomerAccountResource', () => { it('responds with the correct data', async function() { - const response = await accountsAndCustomersService.getFullCustomerAccountResource(process.env.API_CUSTOMER_ID!, process.env.API_ACCOUNT_NUMBER!) + const response = await accountsAndCustomersService.getFullCustomerAccountResource('me', process.env.API_ACCOUNT_NUMBER!) expect(response["account-number"]).toBeDefined(); expect(response["margin-or-cash"]).toBeDefined(); expect(response["investment-objective"]).toBeDefined(); diff --git a/tests/integration/service/balances-and-positions-service.test.ts b/tests/integration/service/balances-and-positions-service.test.ts index db70edf..c077ee6 100644 --- a/tests/integration/service/balances-and-positions-service.test.ts +++ b/tests/integration/service/balances-and-positions-service.test.ts @@ -1,8 +1,6 @@ import BalancesAndPositionsService from "../../../lib/services/balances-and-positions-service"; import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client"; import SessionService from "../../../lib/services/session-service"; -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const balancesAndPositionsService = new BalancesAndPositionsService(client) diff --git a/tests/integration/service/instruments-service.test.ts b/tests/integration/service/instruments-service.test.ts index 076f29d..fc07045 100644 --- a/tests/integration/service/instruments-service.test.ts +++ b/tests/integration/service/instruments-service.test.ts @@ -2,8 +2,6 @@ import InstrumentsService from "../../../lib/services/instruments-service" import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client" import SessionService from "../../../lib/services/session-service" import _ from 'lodash' -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const instrumentsService = new InstrumentsService(client) diff --git a/tests/integration/service/margin-requirements-service.test.ts b/tests/integration/service/margin-requirements-service.test.ts index e3a0fad..26b55e9 100644 --- a/tests/integration/service/margin-requirements-service.test.ts +++ b/tests/integration/service/margin-requirements-service.test.ts @@ -1,8 +1,6 @@ import MarginRequirementsService from "../../../lib/services/margin-requirements-service"; import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client"; import SessionService from "../../../lib/services/session-service"; -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const marginRequirementsService = new MarginRequirementsService(client) diff --git a/tests/integration/service/orders-service.test.ts b/tests/integration/service/orders-service.test.ts index 711ef78..2043266 100644 --- a/tests/integration/service/orders-service.test.ts +++ b/tests/integration/service/orders-service.test.ts @@ -1,8 +1,6 @@ import OrderService from "../../../lib/services/orders-service" import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client"; import SessionService from "../../../lib/services/session-service"; -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const orderService = new OrderService(client) @@ -12,16 +10,6 @@ beforeAll(async () => { await sessionService.login(process.env.API_USERNAME!, process.env.API_PASSWORD!) }); -// OrderID ambiguous -// describe('getOrder', () => { -// it('responds with the correct data', async function() { -// const orderId = 10; -// const response = await orderService.getOrder(process.env.API_ACCOUNT_NUMBER!, orderId) -// expect(response).toBeDefined() -// //Not sure what else it should be checking. -// }) -// }) - describe('getLiveOrders', () => { it('responds with the correct data', async function() { const response = await orderService.getLiveOrders(process.env.API_ACCOUNT_NUMBER!) @@ -36,20 +24,4 @@ describe('getOrders', () => { expect(response).toBeDefined() //Not sure what else it should be checking. }) -}) - -// describe('getLiveOrdersForCustomer', () => { -// it('responds with the correct data', async function() { -// const response = await orderService.getLiveOrdersForCustomer(process.env.API_CUSTOMER_ID!) -// expect(response).toBeDefined() -// //Not sure what else it should be checking. -// }) -// }) - -// describe('getCustomerOrders', () => { -// it('responds with the correct data', async function() { -// const response = await orderService.getCustomerOrders(process.env.API_CUSTOMER_ID!) -// expect(response).toBeDefined() -// //Not sure what else it should be checking. -// }) -// }) +}) \ No newline at end of file diff --git a/tests/integration/service/risk-parameters-service.test.ts b/tests/integration/service/risk-parameters-service.test.ts index 4deefb2..1b83364 100644 --- a/tests/integration/service/risk-parameters-service.test.ts +++ b/tests/integration/service/risk-parameters-service.test.ts @@ -1,8 +1,6 @@ import RiskParametersService from "../../../lib/services/risk-parameters-service" import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client"; import SessionService from "../../../lib/services/session-service"; -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const riskParametersService = new RiskParametersService(client) diff --git a/tests/integration/service/session-service.test.ts b/tests/integration/service/session-service.test.ts index 52e2ae2..bb68920 100644 --- a/tests/integration/service/session-service.test.ts +++ b/tests/integration/service/session-service.test.ts @@ -1,7 +1,5 @@ import SessionService from "../../../lib/services/session-service" import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client"; -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const sessionService = new SessionService(client) diff --git a/tests/integration/service/symbol-search-service.test.ts b/tests/integration/service/symbol-search-service.test.ts index c30792a..5636703 100644 --- a/tests/integration/service/symbol-search-service.test.ts +++ b/tests/integration/service/symbol-search-service.test.ts @@ -1,8 +1,6 @@ import SymbolSearchService from "../../../lib/services/symbol-search-service" import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client"; import SessionService from "../../../lib/services/session-service"; -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const symbolSearchService = new SymbolSearchService(client) diff --git a/tests/integration/service/transactions-service.test.ts b/tests/integration/service/transactions-service.test.ts index 893f6b5..acc1adf 100644 --- a/tests/integration/service/transactions-service.test.ts +++ b/tests/integration/service/transactions-service.test.ts @@ -1,8 +1,6 @@ import TransactionsService from "../../../lib/services/transactions-service" import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client"; import SessionService from "../../../lib/services/session-service"; -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const transactionsService = new TransactionsService(client) @@ -12,27 +10,10 @@ beforeAll(async () => { await sessionService.login(process.env.API_USERNAME!, process.env.API_PASSWORD!) }); -// Ignoring for now, need to create a transaction that won’t get purged from the cert environment -// describe('getEffectiveMarginRequirements', () => { -// it('responds with a 404', async function() { -// const client = new TastytradeHttpClient(process.env.BASE_URL!) -// await transactionsService.getTransaction('fakeAccountNumber', 'fakeID') -// throw new Error('Expected 404 but none was thrown') -// }) - -// it('responds with the correct data', async function() { -// const client = new TastytradeHttpClient(process.env.BASE_URL!) -// const response = await transactionsService.getTransaction(process.env.API_ACCOUNT_NUMBER!, process.env.API_ID!) -// expect(response).toBeDefined() -// //Not sure what else it should be checking. -// }) -// }) - describe('getTotalFees', () => { it('responds with the correct data', async function() { const response = await transactionsService.getTotalFees(process.env.API_ACCOUNT_NUMBER!) expect(response).toBeDefined() - //Not sure what else it should be checking. }) }) @@ -40,6 +21,5 @@ describe('getAccountTransactions', () => { it('responds with the correct data', async function() { const response = await transactionsService.getAccountTransactions(process.env.API_ACCOUNT_NUMBER!) expect(response).toBeDefined() - //Not sure what else it should be checking. }) }) diff --git a/tests/integration/service/watchlists-service.test.ts b/tests/integration/service/watchlists-service.test.ts index 571d3cf..83d70a1 100644 --- a/tests/integration/service/watchlists-service.test.ts +++ b/tests/integration/service/watchlists-service.test.ts @@ -1,8 +1,6 @@ import WatchlistsService from "../../../lib/services/watchlists-service" import TastytradeHttpClient from "../../../lib/services/tastytrade-http-client"; import SessionService from "../../../lib/services/session-service"; -import * as dotenv from 'dotenv' -dotenv.config() const client = new TastytradeHttpClient(process.env.BASE_URL!) const watchlistsService = new WatchlistsService(client)