Skip to content

Commit

Permalink
feat: added isInTestMode method to Application
Browse files Browse the repository at this point in the history
  • Loading branch information
mvegter committed May 1, 2020
1 parent fb3d5a0 commit e56c70d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ class BookkeepingApplication extends IApplication {
this.database = database;
}

/**
* Returns wether or not to the application is in test mode.
*
* @returns {Boolean} Wether or not to the application is in test mode.
*/
isInTestMode() {
return process.env.NODE_ENV === 'test';
}

/**
* Causes the application to be scheduled for execution.
*
Expand All @@ -44,7 +53,7 @@ class BookkeepingApplication extends IApplication {
await this.database.connect();
await this.database.migrate();

if (process.env.NODE_ENV === 'test') {
if (this.isInTestMode()) {
await this.database.seed();
}

Expand Down
9 changes: 9 additions & 0 deletions lib/application/interfaces/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
* Application
*/
class Application {
/**
* Returns wether or not to the application is in test mode.
*
* @returns {Boolean} Wether or not to the application is in test mode.
*/
isInTestMode() {
throw new Error('The method or operation is not implemented.');
}

/**
* Causes the application to be scheduled for execution.
*
Expand Down

0 comments on commit e56c70d

Please sign in to comment.