mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Decorate category hashtag links.
This commit is contained in:
22
test/javascripts/lib/category-hashtags-test.js.es6
Normal file
22
test/javascripts/lib/category-hashtags-test.js.es6
Normal 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');
|
||||
});
|
||||
Reference in New Issue
Block a user