mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 21:21:19 +08:00
ES6: Convert all test files over
This commit is contained in:
30
test/javascripts/admin/models/admin-user-test.js.es6
Normal file
30
test/javascripts/admin/models/admin-user-test.js.es6
Normal file
@ -0,0 +1,30 @@
|
||||
module("Discourse.AdminUser");
|
||||
|
||||
|
||||
asyncTestDiscourse('generate key', function() {
|
||||
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve({api_key: {id: 1234, key: 'asdfasdf'}}));
|
||||
|
||||
var adminUser = Discourse.AdminUser.create({id: 333});
|
||||
|
||||
blank(adminUser.get('api_key'), 'it has no api key by default');
|
||||
adminUser.generateApiKey().then(function() {
|
||||
start();
|
||||
ok(Discourse.ajax.calledWith("/admin/users/333/generate_api_key", { type: 'POST' }), "it POSTed to the url");
|
||||
present(adminUser.get('api_key'), 'it has an api_key now');
|
||||
});
|
||||
});
|
||||
|
||||
asyncTestDiscourse('revoke key', function() {
|
||||
|
||||
var apiKey = Discourse.ApiKey.create({id: 1234, key: 'asdfasdf'}),
|
||||
adminUser = Discourse.AdminUser.create({id: 333, api_key: apiKey});
|
||||
|
||||
sandbox.stub(Discourse, 'ajax').returns(Ember.RSVP.resolve());
|
||||
|
||||
equal(adminUser.get('api_key'), apiKey, 'it has the api key in the beginning');
|
||||
adminUser.revokeApiKey().then(function() {
|
||||
start();
|
||||
ok(Discourse.ajax.calledWith("/admin/users/333/revoke_api_key", { type: 'DELETE' }), "it DELETEd to the url");
|
||||
blank(adminUser.get('api_key'), 'it cleared the api_key');
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user