2015-08-18 21:24:09 -04:00
|
|
|
import Badge from 'discourse/models/badge';
|
|
|
|
|
2015-08-07 15:08:27 -04:00
|
|
|
moduleFor('controller:admin-user-badges', {
|
2015-02-15 20:37:11 -05:00
|
|
|
needs: ['controller:adminUser']
|
|
|
|
});
|
|
|
|
|
|
|
|
test("grantableBadges", function() {
|
2015-08-18 21:24:09 -04:00
|
|
|
const badgeFirst = Badge.create({id: 3, name: "A Badge"});
|
|
|
|
const badgeMiddle = Badge.create({id: 1, name: "My Badge"});
|
|
|
|
const badgeLast = Badge.create({id: 2, name: "Zoo Badge"});
|
|
|
|
const controller = this.subject({ badges: [badgeLast, badgeFirst, badgeMiddle] });
|
|
|
|
const sortedNames = [badgeFirst.name, badgeMiddle.name, badgeLast.name];
|
|
|
|
const badgeNames = controller.get('grantableBadges').map(function(badge) {
|
2015-02-15 20:37:11 -05:00
|
|
|
return badge.name;
|
|
|
|
});
|
|
|
|
|
2015-08-18 21:24:09 -04:00
|
|
|
deepEqual(badgeNames, sortedNames, "sorts badges by name");
|
2015-02-15 20:37:11 -05:00
|
|
|
});
|