Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca7d09a

Browse files
BinaryMusekuychaco
authored andcommitted
Add GithubLoginModel tests
1 parent bec83bd commit ca7d09a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import GithubLoginModel, {KeytarStrategy, SecurityBinaryStrategy, UNAUTHENTICATED} from '../../lib/models/github-login-model';
2+
3+
describe('GithubLoginModel', function() {
4+
[KeytarStrategy, SecurityBinaryStrategy].forEach(function(Strategy) {
5+
if (Strategy.isValid()) {
6+
describe(Strategy.name, function() {
7+
it('manages passwords', async function() {
8+
const loginModel = new GithubLoginModel(Strategy);
9+
const callback = sinon.stub();
10+
loginModel.onDidUpdate(callback);
11+
const TOKEN = 'TOKEN';
12+
13+
await loginModel.setToken('test-account', TOKEN);
14+
assert.equal(callback.callCount, 1);
15+
assert.equal(await loginModel.getToken('test-account'), TOKEN);
16+
await loginModel.removeToken('test-account');
17+
assert.equal(await loginModel.getToken('test-account'), UNAUTHENTICATED);
18+
});
19+
});
20+
} else {
21+
// eslint-disable-next-line no-console
22+
console.warn(
23+
`Skipping tests for ${Strategy} as they are not supported on this platform (maybe your Atom is unsigned?)`,
24+
);
25+
}
26+
});
27+
});

0 commit comments

Comments
 (0)