forked from PluralFlux/PluralFlux
imported env files better
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
**/.dockerignore
|
**/.dockerignore
|
||||||
**/.env
|
.env.jest
|
||||||
**/.git
|
**/.git
|
||||||
**/.gitignore
|
**/.gitignore
|
||||||
**/.project
|
**/.project
|
||||||
|
|||||||
2
.env.jest
Normal file
2
.env.jest
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
FLUXER_BOT_TOKEN=jest-fluxer-bot-token
|
||||||
|
POSTGRES_PASSWORD=jest-postgres-password
|
||||||
@@ -3,12 +3,12 @@ import { messageHelper } from "./helpers/messageHelper.js";
|
|||||||
import {enums} from "./enums.js";
|
import {enums} from "./enums.js";
|
||||||
import {commands} from "./commands.js";
|
import {commands} from "./commands.js";
|
||||||
import {webhookHelper} from "./helpers/webhookHelper.js";
|
import {webhookHelper} from "./helpers/webhookHelper.js";
|
||||||
import * as env from 'dotenv';
|
import env from 'dotenv';
|
||||||
import {utils} from "./helpers/utils.js";
|
import {utils} from "./helpers/utils.js";
|
||||||
|
|
||||||
env.config();
|
env.config({path: './.env'});
|
||||||
|
|
||||||
const token = process.env.FLUXER_BOT_TOKEN;
|
export const token = process.env.FLUXER_BOT_TOKEN;
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
console.error("Missing FLUXER_BOT_TOKEN environment variable.");
|
console.error("Missing FLUXER_BOT_TOKEN environment variable.");
|
||||||
@@ -84,6 +84,7 @@ export const debounceLogin = utils.debounce(client.login, 60000);
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
await client.login(token);
|
await client.login(token);
|
||||||
// await db.check_connection();
|
// await db.check_connection();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const env = require('dotenv');
|
const env = require('dotenv').config({path: './.env.jest'})
|
||||||
const {enums} = require("../src/enums.js");
|
const {enums} = require("../src/enums.js");
|
||||||
|
|
||||||
jest.mock('@fluxerjs/core', () => {
|
jest.mock('@fluxerjs/core', () => {
|
||||||
@@ -59,12 +59,9 @@ const {commands} = require("../src/commands.js");
|
|||||||
const {webhookHelper} = require("../src/helpers/webhookHelper.js");
|
const {webhookHelper} = require("../src/helpers/webhookHelper.js");
|
||||||
|
|
||||||
const {utils} = require("../src/helpers/utils.js");
|
const {utils} = require("../src/helpers/utils.js");
|
||||||
let {handleMessageCreate, client, debounceLogin} = require("../src/bot.js");
|
let {handleMessageCreate, client} = require("../src/bot.js");
|
||||||
|
|
||||||
env.config();
|
|
||||||
|
|
||||||
describe('bot', () => {
|
describe('bot', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
@@ -74,6 +71,7 @@ describe('bot', () => {
|
|||||||
|
|
||||||
test('on message creation, if message is from bot, return', () => {
|
test('on message creation, if message is from bot, return', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
console.log(env)
|
||||||
const message = {
|
const message = {
|
||||||
author: {
|
author: {
|
||||||
bot: true
|
bot: true
|
||||||
|
|||||||
Reference in New Issue
Block a user