ember-cli-mirage-nested
This addon does two different things at the moment and will be soon split into ember-cli-mirage-scenario-chaining and ember-cli-mirage-gui
Demo
https://britishgas-engineering.github.io/ember-cli-mirage-nested
1) ember-cli-mirage-scenario-chaining
Define your Mirage scenario with nested syntax such as:
server;
Features
We created a few very useful methods to be used on Mirage models (once they are extended using our mixin), allowing to easily create scenarii:
hasOne
: the parent model instance has one and only one child model instance (given a relationship parent to child has been set). example:
//mirage/scenarios/default.jsconst parent = server;const child = parentparentchild === child //true
hasMulti
: the parent model instance has multiple child model instance (given ahasMany
relationship parent to child has been set). example:
//mirage/scenarios/default.jsconst parent = server;const children = parentparentchildrenmodels === children //true
hasNo
: the parent model instance has no child model instance (given a relationship parent to child has been set). example:
//mirage/scenarios/default.jsconst parent = server;parent;parentchild === null //true
- In addition we added a
default
method available for each Mirage model, which will be run whenever a new model instance is created - similar to aninit
method, this allows to create default children relationships on model creation
Usage
Extend your Mirage models from the bg-model-mixin in this addon, for example:
//mirage/models/bg-model.js;; ;
//mirage/models/parent.js;; ;
2) ember-cli-mirage-gui
This addon adds some methods in Mirage models allowing to create a Graphical User Interface in your app to easily create Mirage scenario, like the one in our demo.
Only alpha version for now (components for the GUI are in the dummy app of this addon), documentation / wiki is in progress.
Set all the options for this functionality in a forGUI
object in your model
//mirage/models/parent.js;; ;