mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:34:31 +08:00
UX: new /categories layout
This commit is contained in:
@ -88,44 +88,6 @@ test('findByIds', function() {
|
||||
deepEqual(Discourse.Category.findByIds([1,2,3]), _.values(categories));
|
||||
});
|
||||
|
||||
test('postCountStats', function() {
|
||||
const store = createStore();
|
||||
const category1 = store.createRecord('category', {id: 1, slug: 'unloved', posts_year: 2, posts_month: 0, posts_week: 0, posts_day: 0}),
|
||||
category2 = store.createRecord('category', {id: 2, slug: 'hasbeen', posts_year: 50, posts_month: 4, posts_week: 0, posts_day: 0}),
|
||||
category3 = store.createRecord('category', {id: 3, slug: 'solastweek', posts_year: 250, posts_month: 200, posts_week: 50, posts_day: 0}),
|
||||
category4 = store.createRecord('category', {id: 4, slug: 'hotstuff', posts_year: 500, posts_month: 280, posts_week: 100, posts_day: 22}),
|
||||
category5 = store.createRecord('category', {id: 6, slug: 'empty', posts_year: 0, posts_month: 0, posts_week: 0, posts_day: 0});
|
||||
|
||||
let result = category1.get('postCountStats');
|
||||
equal(result.length, 1, "should only show year");
|
||||
equal(result[0].value, 2);
|
||||
equal(result[0].unit, 'year');
|
||||
|
||||
result = category2.get('postCountStats');
|
||||
equal(result.length, 2, "should show month and year");
|
||||
equal(result[0].value, 4);
|
||||
equal(result[0].unit, 'month');
|
||||
equal(result[1].value, 50);
|
||||
equal(result[1].unit, 'year');
|
||||
|
||||
result = category3.get('postCountStats');
|
||||
equal(result.length, 2, "should show week and month");
|
||||
equal(result[0].value, 50);
|
||||
equal(result[0].unit, 'week');
|
||||
equal(result[1].value, 200);
|
||||
equal(result[1].unit, 'month');
|
||||
|
||||
result = category4.get('postCountStats');
|
||||
equal(result.length, 2, "should show day and week");
|
||||
equal(result[0].value, 22);
|
||||
equal(result[0].unit, 'day');
|
||||
equal(result[1].value, 100);
|
||||
equal(result[1].unit, 'week');
|
||||
|
||||
result = category5.get('postCountStats');
|
||||
equal(result.length, 0, "should show nothing");
|
||||
});
|
||||
|
||||
test('search with category name', () => {
|
||||
const store = createStore(),
|
||||
category1 = store.createRecord('category', { id: 1, name: 'middle term', slug: 'different-slug' }),
|
||||
|
Reference in New Issue
Block a user