Skip to content

Commit

Permalink
feat: add no feature config available
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestoteo committed Nov 7, 2024
1 parent 1c7e986 commit 077bd3d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions test/mocks/mocks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
module.exports = {
mockConfigsWithNoFeauture: {
features: {
no_feature: {
form_name: 'no_form'
},
},
},
stockOutMockConfigs: {
features: {
stock_out: {
Expand Down
15 changes: 13 additions & 2 deletions test/stock-out-feature.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ExcelJS = require('exceljs');
const fs = require('fs');
const path = require('path');
const { stockOutMockConfigs } = require('./mocks/mocks');
const { stockOutMockConfigs, mockConfigsWithNoFeauture } = require('./mocks/mocks');
const { updateStockOut } = require('../src/features/stock-out');
const {
setDirToprojectConfig,
Expand All @@ -10,6 +10,7 @@ const {

describe('updateStockOut', () => {
const workingDir = process.cwd();
const createdAppFormFiles = ['stock_out.properties.json', 'stock_out.xlsx'];

beforeEach(() => {
setDirToprojectConfig();
Expand All @@ -20,9 +21,19 @@ describe('updateStockOut', () => {
revertBackToProjectHome(workingDir);
});

it('should not generate and update stock out form', async () => {
const projectDataDir = process.cwd();
// Check that stock out 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 updateStockOut and check it throws an exception when there is no match config
await expect( updateStockOut(mockConfigsWithNoFeauture)).rejects.toThrow(Error);

});

it('should update the stock out form with correct values', async () => {
const createdAppFormFiles = ['stock_out.properties.json', 'stock_out.xlsx'];
const processDir = process.cwd();

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

0 comments on commit 077bd3d

Please sign in to comment.