marmelab / FakeRest

Patch fetch/XMLHttpRequest to fake a REST API server in the browser, based on JSON data.
MIT License
439 stars 48 forks source link

[RFR] Add Filtering capabilities for array properties #13

Closed fzaninotto closed 9 years ago

fzaninotto commented 9 years ago
var collection = new Collection([
    { tags: ['a', 'b', 'c'] },
    { tags: ['b', 'c', 'd'] },
    { tags: ['c', 'd', 'e'] },
]);
var expected = [
    { id: 0, tags: ['a', 'b', 'c'] },
    { id: 1, tags: ['b', 'c', 'd'] },
];
expect(collection.getAll({filter: { tags: 'b' } })).toEqual(expected)
expect(collection.getAll({filter: { tags: 'f' } })).toEqual([])