Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Minor test fixes #211

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"jasmine": "^4.5.0",
"jasmine-spec-reporter": "^7.0.0",
"nyc": "^15.1.0",
"rewire": "^6.0.0"
"rewire": "^6.0.0",
"tmp": "^0.2.3"
},
"nyc": {
"all": true,
Expand Down
7 changes: 5 additions & 2 deletions spec/ConfigChanges/ConfigChanges.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
*/

const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const et = require('elementtree');
const tmp = require('tmp');

tmp.setGracefulCleanup();

const configChanges = require('../../src/ConfigChanges/ConfigChanges');
const mungeutil = require('../../src/ConfigChanges/munge-util');
Expand Down Expand Up @@ -54,7 +56,8 @@ const varplugin = path.join(fixturePath, 'plugins/com.adobe.vars');
const plistplugin = path.join(fixturePath, 'plugins/org.apache.plist');
const bplistplugin = path.join(fixturePath, 'plugins/org.apache.bplist');

const temp = path.join(os.tmpdir(), 'plugman');
const tempdir = tmp.dirSync({ unsafeCleanup: true });
const temp = path.join(tempdir.name, 'plugman');
const plugins_dir = path.join(temp, 'cordova', 'plugins');

const cfg = new ConfigParser(xml);
Expand Down
36 changes: 34 additions & 2 deletions spec/FileUpdater.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,42 @@ FileUpdater.__set__('updatePathWithStats', function () {

// Create mock fs.Stats to simulate file or directory attributes.
function mockFileStats (modified) {
return new Stats(0, 32768, 0, 0, 0, 0, 0, 0, 0, 0, null, modified, modified, null);
return {
__proto__: Stats.prototype,
dev: 0,
mode: 32768,
nlink: 0,
uid: 0,
gid: 0,
rdev: 0,
blksize: 0,
ino: 0,
size: 0,
blocks: 0,
atime: null,
mtime: modified,
ctime: modified,
birthtime: null
};
}
function mockDirStats () {
return new Stats(0, 16384, 0, 0, 0, 0, 0, 0, 0, 0, null, null, null, null);
return {
__proto__: Stats.prototype,
dev: 0,
mode: 16384,
nlink: 0,
uid: 0,
gid: 0,
rdev: 0,
blksize: 0,
ino: 0,
size: 0,
blocks: 0,
atime: null,
mtime: null,
ctime: null,
birthtime: null
};
}

class SystemError extends Error {
Expand Down