mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
FEATURE: User Directory, with sorting and time period filter
This commit is contained in:
28
test/javascripts/models/result-set-test.js.es6
Normal file
28
test/javascripts/models/result-set-test.js.es6
Normal file
@ -0,0 +1,28 @@
|
||||
module('result-set');
|
||||
|
||||
import ResultSet from 'discourse/models/result-set';
|
||||
import createStore from 'helpers/create-store';
|
||||
|
||||
test('defaults', function() {
|
||||
const rs = ResultSet.create({ content: [] });
|
||||
equal(rs.get('length'), 0);
|
||||
equal(rs.get('totalRows'), 0);
|
||||
ok(!rs.get('loadMoreUrl'));
|
||||
ok(!rs.get('loading'));
|
||||
ok(!rs.get('loadingMore'));
|
||||
});
|
||||
|
||||
test('pagination support', function() {
|
||||
const store = createStore();
|
||||
store.findAll('widget').then(function(rs) {
|
||||
equal(rs.get('length'), 2);
|
||||
equal(rs.get('totalRows'), 4);
|
||||
ok(rs.get('loadMoreUrl'), 'has a url to load more');
|
||||
|
||||
rs.loadMore().then(function() {
|
||||
equal(rs.get('length'), 4);
|
||||
ok(!rs.get('loadMoreUrl'));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -19,7 +19,20 @@ test('find', function() {
|
||||
store.find('widget', 123).then(function(w2) {
|
||||
equal(w, w2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('find with object id', function() {
|
||||
const store = createStore();
|
||||
store.find('widget', {id: 123}).then(function(w) {
|
||||
equal(w.get('firstObject.name'), 'Trout Lure');
|
||||
});
|
||||
});
|
||||
|
||||
test('find with query param', function() {
|
||||
const store = createStore();
|
||||
store.find('widget', {name: 'Trout Lure'}).then(function(w) {
|
||||
equal(w.get('firstObject.id'), 123);
|
||||
});
|
||||
});
|
||||
|
||||
@ -33,7 +46,7 @@ test('update', function() {
|
||||
test('findAll', function() {
|
||||
const store = createStore();
|
||||
store.findAll('widget').then(function(result) {
|
||||
equal(result.length, 2);
|
||||
equal(result.get('length'), 2);
|
||||
const w = result.findBy('id', 124);
|
||||
equal(w.get('name'), 'Evil Repellant');
|
||||
});
|
||||
|
Reference in New Issue
Block a user