Skip to content

Commit

Permalink
Jest config updates and dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoss18 committed Jul 3, 2023
1 parent 570ba5a commit 0b43f5b
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 71 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
setupFiles: ["dotenv/config"],
testEnvironment: 'node',
transform: {
'^.+\\.ts?$': 'ts-jest',
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/service/account-status-service.test.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 4 additions & 6 deletions tests/integration/service/accounts-and-customers-service.test.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/service/instruments-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/service/margin-requirements-service.test.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
30 changes: 1 addition & 29 deletions tests/integration/service/orders-service.test.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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!)
Expand All @@ -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.
// })
// })
})
2 changes: 0 additions & 2 deletions tests/integration/service/risk-parameters-service.test.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/service/session-service.test.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/service/symbol-search-service.test.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
20 changes: 0 additions & 20 deletions tests/integration/service/transactions-service.test.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -12,34 +10,16 @@ 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.
})
})

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.
})
})
2 changes: 0 additions & 2 deletions tests/integration/service/watchlists-service.test.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 0b43f5b

Please sign in to comment.