Skip to content

Commit

Permalink
fix tests for windows/linux
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomontero committed Nov 23, 2023
1 parent e35d548 commit b7aa50c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cmd/logic-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const settings = require('../../settings');
const { normalizedApiError } = require('../lib/api-client');
const { copyAndReplaceTemplate, hasTemplateFiles } = require('../lib/template-processor');

const logicFunctionTemplatePath = __dirname + '/../../assets/logicFunction';
const logicFunctionTemplatePath = path.join(__dirname, '/../../assets/logicFunction');

/**
* Commands for managing encryption keys.
Expand Down
11 changes: 7 additions & 4 deletions src/cmd/logic-function.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ describe('LogicFunctionCommands', () => {
const filePaths = await logicFunctionCommands.create({
params: { filepath: PATH_TMP_DIR }
});
const expectedFiles = ['logic-func-1/code.js', 'logic-func-1/configuration.json'];
// Iterate through each file path and check inclusion
expect(filePaths.length).to.equal(2);
const expectedFiles = [
path.join('logic-func-1', 'code.js'),
path.join('logic-func-1', 'configuration.json')
];
for (const expectedFile of expectedFiles) {
const includesExpected = filePaths.some(value => value.includes(expectedFile));
expect(includesExpected, `File path "${expectedFile}" does not include expected values`).to.be.true;
Expand All @@ -150,8 +153,8 @@ describe('LogicFunctionCommands', () => {
nock('https://api.particle.io/v1', )
.intercept('/logic/functions', 'GET')
.reply(200, { logic_functions: [] });
fs.createFileSync(path.join(PATH_TMP_DIR, 'logicFunc1', 'code.js'));
fs.createFileSync(path.join(PATH_TMP_DIR, 'logicFunc1', 'configuration.json'));
await fs.createFile(path.join(PATH_TMP_DIR, 'logicFunc1', 'code.js'));
await fs.createFile(path.join(PATH_TMP_DIR, 'logicFunc1', 'configuration.json'));
logicFunctionCommands.ui.prompt = sinon.stub();
logicFunctionCommands.ui.prompt.onCall(0).resolves({ name: 'logicFunc1' });
logicFunctionCommands.ui.prompt.onCall(1).resolves({ description: 'Logic Function 1' });
Expand Down

0 comments on commit b7aa50c

Please sign in to comment.