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

Merge pull request #268 from hbeeken/test-coverage

Adding unit test for credentials.clean
This commit is contained in:
Nick O'Leary 2014-07-16 10:53:25 +01:00
commit b7a83383c9

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();
});
});
}) })