discourse/test/javascripts/admin/controllers/admin-user-badges-test.js.es6

26 lines
1.0 KiB
Plaintext
Raw Normal View History

2015-08-18 21:24:09 -04:00
import Badge from 'discourse/models/badge';
2016-11-08 14:29:50 -05:00
import { mapRoutes } from 'discourse/mapping-router';
2015-08-18 21:24:09 -04:00
2015-08-07 15:08:27 -04:00
moduleFor('controller:admin-user-badges', {
2016-11-08 14:29:50 -05:00
setup() {
this.registry.register('router:main', mapRoutes());
},
needs: ['controller:adminUser']
});
test("grantableBadges", function() {
const badgeFirst = Badge.create({id: 3, name: "A Badge", enabled: true});
const badgeMiddle = Badge.create({id: 1, name: "My Badge", enabled: true});
const badgeLast = Badge.create({id: 2, name: "Zoo Badge", enabled: true});
const badgeDisabled = Badge.create({id: 4, name: "Disabled Badge", enabled: false});
const controller = this.subject({ model: [], badges: [badgeLast, badgeFirst, badgeMiddle, badgeDisabled] });
2015-08-18 21:24:09 -04:00
const sortedNames = [badgeFirst.name, badgeMiddle.name, badgeLast.name];
const badgeNames = controller.get('grantableBadges').map(function(badge) {
return badge.name;
});
not(badgeNames.contains(badgeDisabled), "excludes disabled badges");
2015-08-18 21:24:09 -04:00
deepEqual(badgeNames, sortedNames, "sorts badges by name");
});