Ghost/ghost/admin/mirage/config/labels.js
Rishabh Garg 78e453c1b0 Fixed tests for labels (#1493)
no issue

- Updated member settings css property in tests
- Added mock for label API
2020-02-14 16:37:25 +05:30

28 lines
710 B
JavaScript

import {paginatedResponse} from '../utils';
export default function mockLabels(server) {
server.post('/labels/', function ({labels}) {
let attrs = this.normalizedRequestAttrs();
return labels.create(Object.assign({}, attrs, {id: 99}));
});
server.get('/labels/', paginatedResponse('labels'));
server.get('/labels/:id/', function ({labels}, {params}) {
let {id} = params;
let label = labels.find(id);
return label || new Response(404, {}, {
errors: [{
type: 'NotFoundError',
message: 'Label not found.'
}]
});
});
server.put('/labels/:id/');
server.del('/labels/:id/');
}