lundi 2 octobre 2017

How to seed firebase before acceptance tests in ember?

I'm trying to seed firebase in ember app with some code like this

moduleForAcceptance(name, {
    beforeEach () {
      scenarioDefault(server)

      stubFirebase()
      this.firebaseReference = createOfflineFirebaseReference(FIXTURE_DATA)
      replaceFirebaseReference(this.application, this.firebaseReference)

      if (options.beforeEach) {
        options.beforeEach.apply(this, arguments)
      }
    },

    afterEach () {
      if (options.afterEach) {
        options.afterEach.apply(this, arguments)
      }

      unstubFirebase()
    }
  })

And FIXTURE_DATA looks like

export default {

  "monthWeeks": {
    "month_1_tree_1_week_1": {
      "monthTree": "month_1_tree_1",
      "name": "1_Week_Name",
      "position": 0
    }
  },

  "monthTrees": {
    "month_1_tree_1": {
      "month": "month_1",
      "monthWeeks": {
        "month_1_tree_1_week_1": true
      }
    }
  },

  "months": {
    "month_1": {
      "name": "1_Name",
      "monthTree": "month_1_tree_1"
    },
    "month_2": {
      "name": "2_Name"
    }
  }
}

and I use firebase adapter for 'month' 'monthTree' and 'monthWeek' models. But by debugging i see that store contains all models ('months' 'monthTrees' and 'monthWeeks') but they are not in tree structure, how they was sent to offline ref. And I can't get month.get('monthTree.monthWeeks.firstObject'), bc there are no 'monthWeeks'

any ideas, what can be reason? thanks!




Aucun commentaire:

Enregistrer un commentaire