Skip to content

Commit

Permalink
chore: Tried to fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan van Rooij committed May 3, 2020
1 parent 827a487 commit 6881578
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 24 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Expand Up @@ -162,7 +162,7 @@ module.exports = {

// This option allows use of a custom test runner
// testRunner: "jasmine2",
testTimeout: 10000,
testTimeout: 15000,

// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",
Expand Down
6 changes: 3 additions & 3 deletions test/pass.js
Expand Up @@ -21,9 +21,9 @@ describe('PASS command', () => {
client = new Client(options);
client.auth(options.user, badPass, (error) => {
error.code.should.eql(530);
client.raw.user(options.user, (error, reply) => {
client.raw('user', options.user, (error, reply) => {
reply.code.should.eql(331);
client.raw.pass(badPass, (error) => {
client.raw('pass', badPass, (error) => {
error.code.should.eql(530);
done();
});
Expand All @@ -33,7 +33,7 @@ describe('PASS command', () => {

test('should reject PASS without USER', (done) => {
client = new Client(options);
client.raw.pass(options.pass, (error) => {
client.raw('pass', options.pass, (error) => {
error.code.should.eql(503);
done();
});
Expand Down
28 changes: 17 additions & 11 deletions test/pwd.js
Expand Up @@ -16,30 +16,35 @@ describe('PWD command', () => {
undefined,
];

const options = {
port: 7030
}

directories.forEach((directory) => {
describe(`CWD = "${directory}"`, () => {
beforeEach((done) => {
server = common.server({
getInitialCwd() {
return directory;
},
port: options.port
});
client = common.client(done);
client = common.client(done, options);
});

test(`should be "${directory}"`, (done) => {
client.raw.pwd((error, reply) => {
common.should.not.exist(error);
reply.code.should.equal(257);
client.raw('pwd', (error, reply) => {
expect(error).toBeNull();
expect(reply.code).toBe(257);
reply.text.should.startWith(`257 "${directory}"`);
done();
});
});

test('should reject parameters', (done) => {
client.raw.pwd(directory, (error, reply) => {
error.code.should.equal(501);
reply.code.should.equal(501);
client.raw('pwd', directory, (error, reply) => {
expect(reply.code).toBe(501);
expect(error.code).toBe(501);
done();
});
});
Expand All @@ -57,14 +62,15 @@ describe('PWD command', () => {
getInitialCwd() {
return directory;
},
port: options.port
});
client = common.client(done);
client = common.client(done, options);
});

test('should be "/"', (done) => {
client.raw.pwd((error, reply) => {
common.should.not.exist(error);
reply.code.should.equal(257);
client.raw('pwd', (error, reply) => {
expect(error).toBeNull();
expect(reply.code).toBe(257);
reply.text.should.startWith('257 "/"');
done();
});
Expand Down
8 changes: 6 additions & 2 deletions test/unsupported.js
Expand Up @@ -21,9 +21,13 @@ describe('UNSUPPORTED commands', () => {
'CD',
];

const options = {
port: 7040
}

beforeEach((done) => {
server = common.server();
client = common.client(done);
server = common.server(options);
client = common.client(done, options);
});

commands.forEach((command) => {
Expand Down
12 changes: 6 additions & 6 deletions test/user.js
Expand Up @@ -21,9 +21,9 @@ describe('USER command', () => {
});
client = new Client(options);
client.auth(options.user, options.pass, (error) => {
error.code.should.eql(530);
client.raw.user(options.user, (error) => {
error.code.should.eql(530);
expect(error.code).toBe(530);
client.raw('user',options.user, (error) => {
expect(error.code).toBe(530);
done();
});
});
Expand All @@ -34,9 +34,9 @@ describe('USER command', () => {
server = common.server();
client = new Client(options);
client.auth(badUser, options.pass, (error) => {
error.code.should.eql(530);
client.raw.user(badUser, (error) => {
error.code.should.eql(530);
expect(error.code).toBe(530);
client.raw('user', badUser, (error) => {
expect(error.code).toBe(530);
done();
});
});
Expand Down
5 changes: 4 additions & 1 deletion test/whitelisted.js
Expand Up @@ -11,11 +11,14 @@ describe('Whitelisted commands', () => {
'LIST',
'NOOP',
],
port: 7035
};

const clientOptions = { port: options.port };

beforeEach((done) => {
server = common.server(options);
client = common.client(done);
client = common.client(done, clientOptions);
});

test('LIST should be allowed', (done) => {
Expand Down

0 comments on commit 6881578

Please sign in to comment.