mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-30 09:15:02 +02:00
[Ivan Diaz] - #8 - Update fixture structure [skip ci]
This commit is contained in:
parent
1df686b3a1
commit
dc08b8f924
@ -9,4 +9,12 @@ if ( process.env.NODE_ENV !== 'production' ) {
|
||||
window.React = React;
|
||||
}
|
||||
|
||||
//TODO: Add env variable to determinate if it should use fixtures
|
||||
/*
|
||||
if ( process.env.API !== 'production' ) {
|
||||
// Mock API calls
|
||||
require('lib/fixtures/fixtures-loader');
|
||||
}
|
||||
*/
|
||||
|
||||
render(routes, document.getElementById('app'));
|
||||
|
@ -0,0 +1,10 @@
|
||||
module.exports = [
|
||||
{
|
||||
path: 'user/login',
|
||||
time: 1000,
|
||||
response: {
|
||||
'userid': 12,
|
||||
'token': 'CUSTOM_VALUE'
|
||||
}
|
||||
}
|
||||
];
|
@ -1,5 +1,29 @@
|
||||
const _ = require('lodash');
|
||||
const $ = require('jquery');
|
||||
const mockjax = require('jquery-mockjax')($, window);
|
||||
|
||||
let fixtures = (function () {
|
||||
let fixturesData = [];
|
||||
|
||||
return {
|
||||
add(fixtures) {
|
||||
fixturesData.concat(fixtures);
|
||||
},
|
||||
getAll() {
|
||||
return fixturesData;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
// FIXTURES
|
||||
const
|
||||
fixtures.add(require('data/fixtures/user-fixtures'));
|
||||
|
||||
_.each(fixtures.getAll(), function (fixture) {
|
||||
//ADD FIXTURE TO MOCKJAX
|
||||
mockjax({
|
||||
contentType: 'application/json',
|
||||
url: fixture.path,
|
||||
responseTime: fixture.time || 500,
|
||||
responseText: JSON.fixture.response
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user