2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-08 12:06:51 +08:00

Support saving posts via Store

This commit is contained in:
Robin Ward 2015-04-09 14:54:17 -04:00
parent d4a05825da
commit 76f7786d0d
16 changed files with 205 additions and 160 deletions

View file

@ -5,6 +5,8 @@ import createStore from 'helpers/create-store';
test('createRecord', function() {
const store = createStore();
const widget = store.createRecord('widget', {id: 111, name: 'hello'});
ok(!widget.get('isNew'), 'it is not a new record');
equal(widget.get('name'), 'hello');
equal(widget.get('id'), 111);
});
@ -13,6 +15,7 @@ test('createRecord without an `id`', function() {
const store = createStore();
const widget = store.createRecord('widget', {name: 'hello'});
ok(widget.get('isNew'), 'it is a new record');
ok(!widget.get('id'), 'there is no id');
});
@ -21,6 +24,7 @@ test('createRecord without attributes', function() {
const widget = store.createRecord('widget');
ok(!widget.get('id'), 'there is no id');
ok(widget.get('isNew'), 'it is a new record');
});
test('createRecord with a record as attributes returns that record from the map', function() {
@ -36,6 +40,7 @@ test('find', function() {
store.find('widget', 123).then(function(w) {
equal(w.get('name'), 'Trout Lure');
equal(w.get('id'), 123);
ok(!w.get('isNew'), 'found records are not new');
// A second find by id returns the same object
store.find('widget', 123).then(function(w2) {
@ -70,6 +75,7 @@ test('findAll', function() {
store.findAll('widget').then(function(result) {
equal(result.get('length'), 2);
const w = result.findBy('id', 124);
ok(!w.get('isNew'), 'found records are not new');
equal(w.get('name'), 'Evil Repellant');
});
});