Skip to content

Commit

Permalink
Add spec to document working on lists as return value
Browse files Browse the repository at this point in the history
  • Loading branch information
LFDM committed Mar 13, 2017
1 parent 5abe5b2 commit d186922
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/denormalization/index.spec.js
@@ -1,6 +1,6 @@
import { build } from '../builder';
import { denormalizer } from '.';
import { curry, prop, toObject, values } from '../fp';
import { curry, prop, head, last, toObject, values } from '../fp';

const toIdMap = toObject(prop('id'));

Expand Down Expand Up @@ -78,5 +78,22 @@ describe('denormalizer', () => {
.then(() => done());
});
});

describe('with a fn, that returns a list of objects', () => {
it('resolves references to simple id fields', (done) => {
const api = build(config(), [denormalizer()]);
api.message.getMessages()
.then((msgs) => {
const fst = head(msgs);
const snd = last(msgs);
expectResolved('author', users[m1.author])(fst);
expectResolved('recipient', users[m1.recipient])(fst);

expectResolved('author', users[m2.author])(snd);
expectResolved('recipient', users[m2.recipient])(snd);
})
.then(() => done());
});
});
});

0 comments on commit d186922

Please sign in to comment.