Feat:discount expiration date (#403)

* discount expiration validation and testing

* integration testing

* double quotes

* add iso8601 package

* api testing

* add joi validation of start and end dates as well as valid_duration

* valid_duration column

* service testing

* discount validation in services

* integration test with invalid date interval

* include valid_duration when fetching a discount

* rename variable for clarity

* add test for dynamic discount with expiration date

* remove debug code

* adjust tests to reflect valid_duration being included in default fields

* additional discount update validation

* fixed failing test

* set ends_at on dynamic discount creation

* discount integration tests

* removed unused console.log

* removed validation of dynamic discounts by duration and added ends_at to dynamic discount creation

* integration tests for dynamic discount with and without duration

* optional valid duration for dynamic discounts

* allow nullable dynamic discount durations

* expect assertions

* fix unit test after change to dynamic discounts without duration

* change to date instead of string

* add assertions

* error handling

* addressed feedback
This commit is contained in:
pKorsholm
2021-09-30 12:13:59 +02:00
committed by GitHub
parent ae0ab03fac
commit 9b64828ec3
22 changed files with 1009 additions and 21 deletions

View File

@@ -1,16 +1,16 @@
const path = require('path');
const {dropDatabase} = require('pg-god');
const path = require("path")
const { dropDatabase } = require("pg-god")
require('dotenv').config({path: path.join(__dirname, '.env')});
require("dotenv").config({ path: path.join(__dirname, ".env") })
const DB_USERNAME = process.env.DB_USERNAME || 'postgres';
const DB_PASSWORD = process.env.DB_PASSWORD || '';
const DB_USERNAME = process.env.DB_USERNAME || "postgres"
const DB_PASSWORD = process.env.DB_PASSWORD || ""
const pgGodCredentials = {
user: DB_USERNAME,
password: DB_PASSWORD,
};
}
afterAll(() => {
dropDatabase({databaseName: 'medusa-integration'}, pgGodCredentials);
});
dropDatabase({ databaseName: "medusa-integration" }, pgGodCredentials)
})