1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Adding unit test for credentials.clean

This commit is contained in:
hbeeken 2014-07-16 09:25:08 +01:00
parent debd5c4496
commit 1419a79933

View File

@ -90,6 +90,30 @@ describe('Credentials', function() {
}); });
it('clean up from storage', function(done) {
var storage = {
getCredentials: function() {
return when.promise(function(resolve,reject) {
resolve({"a":{"b":1,"c":2}});
});
},
saveCredentials: function(creds) {
return when(true);
}
};
sinon.spy(storage,"saveCredentials");
credentials.init(storage);
credentials.load().then(function() {
should.exist(credentials.get("a"));
credentials.clean(function() {
return false;
});
storage.saveCredentials.callCount.should.be.exactly(1);
should.not.exist(credentials.get("a"));
done();
});
});
}) })