4 Commits

Author SHA1 Message Date
e8f3047ac0 1.0.5 2016-06-01 05:18:08 +02:00
812d28ee3d add typings to package.json 2016-06-01 05:17:49 +02:00
fa301eea71 improved tests and reached 80% coverage milestone. 2016-06-01 05:09:20 +02:00
48ccf317d6 update some cosmetics 2016-06-01 04:25:59 +02:00
6 changed files with 58 additions and 16 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,3 @@
{ {
"mode":"default", "mode":"default"
"coverageTreshold":50
} }

View File

@ -1,8 +1,9 @@
{ {
"name": "smartssh", "name": "smartssh",
"version": "1.0.4", "version": "1.0.5",
"description": "setups SSH quickly and in a painless manner", "description": "setups SSH quickly and in a painless manner",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "(npmts)" "test": "(npmts)"
}, },

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,29 @@ import smartssh = require("../dist/index");
describe("smartssh",function(){ describe("smartssh",function(){
let testSshInstance:smartssh.SshInstance; let testSshInstance:smartssh.SshInstance;
let testSshKey:smartssh.SshKey; let testSshKey:smartssh.SshKey;
describe("SshInstance",function(){ describe(".SshKey",function(){
it("'new' keyword should create a valid SshKey object",function(){
testSshKey = new smartssh.SshKey({
host:"example.com",
private:"someExamplePrivateKey",
public:"someExamplePublicKey"
});
testSshKey.should.be.instanceof(smartssh.SshKey);
});
it(".type should be a valid type",function(){
testSshKey.type.should.equal("duplex");
});
it(".publicKey should be public key",function(){
testSshKey.publicKey.should.equal("someExamplePublicKey");
});
it(".privateKey should be private key",function(){
testSshKey.privateKey.should.equal("someExamplePrivateKey");
});
it(".publicKeyBase64 should be public key base 64 encoded",function(){
testSshKey.publicKeyBase64;
})
});
describe(".SshInstance",function(){
it("'new' keyword should create a new SshInstance object from class",function(){ it("'new' keyword should create a new SshInstance object from class",function(){
testSshInstance = new smartssh.SshInstance(); testSshInstance = new smartssh.SshInstance();
testSshInstance.should.be.instanceof(smartssh.SshInstance); testSshInstance.should.be.instanceof(smartssh.SshInstance);
@ -40,5 +62,5 @@ describe("smartssh",function(){
testSshInstance.removeKey(testSshInstance.getKey("bitbucket.org")); testSshInstance.removeKey(testSshInstance.getKey("bitbucket.org"));
testSshInstance.sshKeys[1].host.should.equal("github.com"); testSshInstance.sshKeys[1].host.should.equal("github.com");
}) })
}) });
}) })

View File

@ -35,10 +35,8 @@ export class SshInstance {
}; };
replaceKey(sshKeyOldArg:SshKey,sshKeyNewArg:SshKey){ replaceKey(sshKeyOldArg:SshKey,sshKeyNewArg:SshKey){
this.sync("from"); this.sync("from");
let filteredArray = this.sshKeyArray.filter((sshKeyArg:SshKey) => { this.removeKey(sshKeyOldArg);
return (sshKeyArg.host == "some"); //TODO this.addKey(sshKeyNewArg);
});
this.sshKeyArray = filteredArray;
this.sync("to"); this.sync("to");
}; };
@ -55,6 +53,7 @@ export class SshInstance {
} }
}; };
get sshKeys():SshKey[] { get sshKeys():SshKey[] {
this.sync("from");
return this.sshKeyArray; return this.sshKeyArray;
} }
sync(directionArg:string){ sync(directionArg:string){