Skip to content

Commit

Permalink
Refactor utility imports and update test configurations
Browse files Browse the repository at this point in the history
The commit organizes the imports from utils directory by moving data processing functions to parsers.js. Also, it updates the test configurations by replacing the deprecated method getConfig with initConfig and changes parameters to make it more representative of deploy conditions. This results in a neater, more intuitive import schema and test set-up, enhancing code readability and understanding.
  • Loading branch information
erikyo committed Dec 11, 2023
1 parent 3f8eb28 commit c635334
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tests/fixtures/wp-package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "wordpress",
"wordpress": {
"name": "wordpress",
"version": "6.4.2",
"language": "en_US",
"config": {
"WP_config": {
"DB_NAME": "my_db_name",
"DB_USER": "my_db_username",
"DB_PASSWORD": "my_db_password",
Expand Down
12 changes: 5 additions & 7 deletions tests/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
const { getConfig, getWordPressDownloadUrl, getDownloadUrl } = require('../lib/utils/data.js');
const { generateSalt, replaceDbConstant, replaceDbConstantBool } = require("../lib/utils/wordpress.js");
const {getDataFromFile} = require("../lib/utils/wordpress");
const { getWordPressDownloadUrl, getDownloadUrl } = require('../lib/utils/data.js');
const { generateSalt, replaceDbConstant, replaceDbConstantBool, getDataFromFile } = require("../lib/utils/parsers.js");
const {initConfig} = require("../lib/utils/data");


describe('getConfig', () => {
it('should read wp-package.json from the root folder and return the default configuration if the file does not exist', async () => {
const argv = undefined;
// Call the function
const config = await getConfig(argv);
const config = await initConfig( 'tests', {version: '5.7.1', language: 'en_US'});
// Assert the result
expect(config).toBeInstanceOf(Object);
expect(config.name).toBe('wordpress');
expect(config.wordpress).toMatchObject({"config": {}});
expect(config.wordpress).toMatchObject({"WP_config": {}, version: '5.7.1', language: 'en_US'});
expect(config.plugins).not.toBeFalsy();
});
});
Expand Down
2 changes: 1 addition & 1 deletion tests/wpConfig.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require("fs");
const path = require("path");
const {parseWpConfig} = require("../lib/utils/wordpress");
const {parseWpConfig} = require("../lib/utils/parsers.js");


describe('parseWpConfig with real file', () => {
Expand Down

0 comments on commit c635334

Please sign in to comment.