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

Decaffeinate config spec #68

Merged
merged 3 commits into from
May 21, 2023
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
51 changes: 0 additions & 51 deletions spec/config-spec.coffee

This file was deleted.

70 changes: 31 additions & 39 deletions spec/config-spec.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,47 @@
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
const path = require('path');
const fs = require('fs-plus');
const temp = require('temp');
const apm = require('../lib/apm-cli');

describe("apm config", function() {
let [atomHome, userConfigPath] = Array.from([]);
describe('apm config', () => {
let userConfigPath;

beforeEach(function() {
beforeEach(() => {
spyOnToken();
silenceOutput();

atomHome = temp.mkdirSync('apm-home-dir-');
const atomHome = temp.mkdirSync('apm-home-dir-');
process.env.ATOM_HOME = atomHome;
userConfigPath = path.join(atomHome, '.apmrc');

// Make sure the cache used is the one for the test env
return delete process.env.npm_config_cache;
delete process.env.npm_config_cache;
2colours marked this conversation as resolved.
Show resolved Hide resolved
});

describe("apm config get", () => it("reads the value from the global config when there is no user config", function() {
const callback = jasmine.createSpy('callback');
apm.run(['config', 'get', 'cache'], callback);

waitsFor('waiting for config get to complete', 600000, () => callback.callCount === 1);

return runs(() => expect(process.stdout.write.argsForCall[0][0].trim()).toBe(path.join(process.env.ATOM_HOME, '.apm')));
}));

return describe("apm config set", () => it("sets the value in the user config", function() {
expect(fs.isFileSync(userConfigPath)).toBe(false);

const callback = jasmine.createSpy('callback');
apm.run(['config', 'set', 'foo', 'bar'], callback);

waitsFor('waiting for config set to complete', 600000, () => callback.callCount === 1);

runs(function() {
expect(fs.isFileSync(userConfigPath)).toBe(true);

callback.reset();
return apm.run(['config', 'get', 'foo'], callback);
describe('apm config get', () => {
it('reads the value from the global config when there is no user config', () => {
const callback = jasmine.createSpy('callback');
apm.run(['config', 'get', 'cache'], callback);
waitsFor('waiting for config get to complete', 600000, () => callback.callCount === 1);
runs(() => {
expect(process.stdout.write.argsForCall[0][0].trim()).toBe(path.join(process.env.ATOM_HOME, '.apm'));
});
});
});

waitsFor('waiting for config get to complete', 600000, () => callback.callCount === 1);

return runs(() => expect(process.stdout.write.argsForCall[0][0].trim()).toBe('bar'));
}));
describe('apm config set', () => {
it('sets the value in the user config', () => {
expect(fs.isFileSync(userConfigPath)).toBe(false);
const callback = jasmine.createSpy('callback');
apm.run(['config', 'set', 'foo', 'bar'], callback);
waitsFor('waiting for config set to complete', 600000, () => callback.callCount === 1);
runs(() => {
expect(fs.isFileSync(userConfigPath)).toBe(true);
callback.reset();
apm.run(['config', 'get', 'foo'], callback);
});
waitsFor('waiting for config get to complete', 600000, () => callback.callCount === 1);
runs(() => {
expect(process.stdout.write.argsForCall[0][0].trim()).toBe('bar');
});
});
});
});
18 changes: 0 additions & 18 deletions spec/spec-helper.coffee

This file was deleted.