Skip to content

Commit

Permalink
feat: add no feature config scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestoteo committed Nov 7, 2024
1 parent edd4443 commit ef01621
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
6 changes: 3 additions & 3 deletions test/stock-discrepancy-feature.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
cleanUp
} = require('./test-utils');

describe('update Stock Supply', () => {
describe('update Stock Discrepancy', () => {
const workingDir = process.cwd();
const createdAppFormFiles = ['stock_discrepancy_resolution.xlsx', 'stock_discrepancy_resolution.properties.json'];

Expand All @@ -24,7 +24,7 @@ describe('update Stock Supply', () => {
jest.clearAllMocks();
});

it('stock return form should should not be generated and updated', async () => {
it('should not be generated and updated stock discrepancy form', async () => {
const projectDataDir = process.cwd();
// Check that stock discrepancy xlsx and properties files does not exist.
for(const createdAppFormFile of createdAppFormFiles){
Expand All @@ -37,7 +37,7 @@ describe('update Stock Supply', () => {
});


it('should update the stock supply form with correct values', async () => {
it('should update the stock discrepancy form with correct values', async () => {
const processDir = process.cwd();

// Check that stock confirmation xlsx and properties files exist.
Expand Down
19 changes: 16 additions & 3 deletions test/stock-received-feature.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs');
const path = require('path');
const { stockSupplyConfig } = require('./mocks/mocks');
const { stockSupplyConfig, mockConfigsWithNoFeauture } = require('./mocks/mocks');
const { updateStockConfirmation } = require('../src/features/stock-received');
const { getTranslations } = require('../src/common');
const {
Expand All @@ -10,7 +10,7 @@ const {
cleanUp
} = require('./test-utils');

describe('update Stock Supply', () => {
describe('update Stock Received', () => {
const workingDir = process.cwd();
const createdAppFormFiles = ['stock_received.xlsx', 'stock_received.properties.json'];

Expand All @@ -25,7 +25,20 @@ describe('update Stock Supply', () => {
jest.clearAllMocks();
});

it('should update the stock supply form with correct values', async () => {

it('should not be generated and updated stock received form', async () => {
const projectDataDir = process.cwd();
// Check that stock discrepancy xlsx and properties files does not exist.
for(const createdAppFormFile of createdAppFormFiles){
expect(fs.existsSync(path.join(projectDataDir, 'forms', 'app', createdAppFormFile))).toBe(false);
}

// Call the function updateStockDiscrepancy and check it throws an exception when there is no match config
await expect( updateStockConfirmation(mockConfigsWithNoFeauture)).rejects.toThrow(Error);

});

it('should update the stock received form with correct values', async () => {
const processDir = process.cwd();

// Check that stock confirmation xlsx and properties files exist.
Expand Down
15 changes: 13 additions & 2 deletions test/stock-supply-feature.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs');
const path = require('path');
const { stockSupplyConfig } = require('./mocks/mocks');
const { stockSupplyConfig, mockConfigsWithNoFeauture } = require('./mocks/mocks');
const { updateStockSupply } = require('../src/features/stock-supply');
const {
setDirToprojectConfig,
Expand All @@ -24,8 +24,19 @@ describe('update Stock Supply', () => {
jest.clearAllMocks();
});

it('should not generate and update stock supply form', async () => {
const projectDataDir = process.cwd();
// Check that stock discrepancy xlsx and properties files does not exist.
for(const createdAppFormFile of createdAppFormFiles){
expect(fs.existsSync(path.join(projectDataDir, 'forms', 'app', createdAppFormFile))).toBe(false);
}

// Call the function updateStockDiscrepancy and check it throws an exception when there is no match config
await expect( updateStockSupply(mockConfigsWithNoFeauture)).rejects.toThrow(Error);

});

it('should update the stock supply form with correct values', async () => {
it('should generate and update the stock supply form with correct values', async () => {
const processDir = process.cwd();

// Check that stock supply xlsx and properties files exist.
Expand Down

0 comments on commit ef01621

Please sign in to comment.