Created
February 28, 2018 18:29
-
-
Save samselikoff/b00b5a190321c8236ee0e0fab200bf65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tests/helpers/push-mirage-db-into-store.js | |
import { registerAsyncHelper } from '@ember/test'; | |
import { run } from '@ember/runloop'; | |
let pushMirageDbIntoStore = function(server, store) { | |
let tables = Object.keys(server.schema); | |
tables.forEach(table => { | |
if (server.schema[table].all) { | |
let all = server.schema[table].all(); | |
let modelName = all.modelName; | |
let serializer = server.serializerOrRegistry | |
.serializerFor(modelName); | |
let originalAlwaysIncludeLinkageData = serializer.alwaysIncludeLinkageData; | |
serializer.alwaysIncludeLinkageData = true; | |
let json = serializer.serialize(all); | |
serializer.alwaysIncludeLinkageData = originalAlwaysIncludeLinkageData; | |
run(() => { | |
store.pushPayload(json); | |
}); | |
} | |
}); | |
} | |
export { pushMirageDbIntoStore }; | |
export default registerAsyncHelper('pushMirageDbIntoStore', function(app) { | |
let store = app.__container__.lookup('service:store'); | |
return pushMirageDbIntoStore(server, store); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!
Source of issue: https://stackoverflow.com/questions/51193119/ember-mirage-not-passing-model-as-an-ember-object