FEATURE: Decorate category hashtag links.

This commit is contained in:
Guo Xiang Tan
2016-01-18 17:08:24 +08:00
parent 0812807a53
commit 4a7f560a35
7 changed files with 144 additions and 40 deletions

View File

@@ -0,0 +1,22 @@
import createStore from 'helpers/create-store';
import Category from 'discourse/models/category';
import { findCategoryByHashtagSlug } from "discourse/lib/category-hashtags";
module("lib:category-hashtags");
test('findCategoryByHashtagSlug', () => {
const store = createStore();
const parentCategory = store.createRecord('category', { slug: 'test1' });
const childCategory = store.createRecord('category', {
slug: 'test2', parentCategory: parentCategory
});
sandbox.stub(Category, 'list').returns([parentCategory, childCategory]);
equal(findCategoryByHashtagSlug('test1'), parentCategory, 'returns the right category');
equal(findCategoryByHashtagSlug('test1:test2'), childCategory, 'returns the right category');
equal(findCategoryByHashtagSlug('#test1'), parentCategory, 'returns the right category');
equal(findCategoryByHashtagSlug('#test1:test2'), childCategory, 'returns the right category');
});