2015-01-21 12:48:15 +08:00
|
|
|
import Ember from "ember";
|
|
|
|
import { test } from 'ember-qunit';
|
|
|
|
import startApp from '../helpers/start-app';
|
|
|
|
var App;
|
|
|
|
|
|
|
|
module('Index', {
|
|
|
|
setup: function() {
|
|
|
|
App = startApp();
|
|
|
|
},
|
|
|
|
teardown: function() {
|
|
|
|
Ember.run(App, App.destroy);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Discussion list loading', function() {
|
2015-01-23 10:18:33 +08:00
|
|
|
expect(3);
|
2015-01-21 12:48:15 +08:00
|
|
|
visit('/').then(function() {
|
2015-01-23 10:18:33 +08:00
|
|
|
equal(find('.discussions-list').length, 1, 'Page contains list of discussions');
|
|
|
|
equal(find('.discussions-list li').length, 20, 'There are 20 discussions in the list');
|
|
|
|
|
|
|
|
click('.control-loadMore').then(function() {
|
|
|
|
equal(find('.discussions-list li').length, 40, 'There are 40 discussions in the list');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Discussion list sorting', function() {
|
|
|
|
expect(1);
|
|
|
|
visit('/').then(function() {
|
|
|
|
fillIn('.control-sort select', 'replies').then(function() {
|
|
|
|
var discussions = find('.discussions-list li');
|
|
|
|
var good = true;
|
|
|
|
var getCount = function(item) {
|
|
|
|
return parseInt(item.find('.count strong').text());
|
|
|
|
};
|
|
|
|
var previousCount = getCount(discussions.eq(0));
|
|
|
|
for (var i = 1; i < discussions.length; i++) {
|
|
|
|
var count = getCount(discussions.eq(i));
|
|
|
|
if (count > previousCount) {
|
|
|
|
good = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
previousCount = count;
|
|
|
|
}
|
|
|
|
ok(good, 'Discussions are listed in order of reply count');
|
|
|
|
});
|
2015-01-21 12:48:15 +08:00
|
|
|
});
|
|
|
|
});
|