How to use the ember-data-factory-guy.mockFindRecord function in ember-data-factory-guy

To help you get started, we’ve selected a few ember-data-factory-guy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
test("returns id succeeds and returns model when id for model type found in store after createRecord", async function(assert) {
    let profileId = 1,
        {store}   = FactoryGuy;

    mockCreate('profile').returns({attrs: {id: profileId}});
    mockFindRecord('profile').returns({id: profileId});

    let newRecord = run(() => store.createRecord('profile', {description: 'foo'}));
    let newProfile = await run(() => newRecord.save());
    let foundRecord = await run(() => store.findRecord('profile', profileId));

    assert.deepEqual(foundRecord, newProfile);
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
test("returns id succeeds and returns model when id for model type found in store after createRecord", async function(assert) {
    let profileId = 1,
        {store}   = FactoryGuy;

    mockCreate('profile').returns({attrs: {id: profileId}});
    mockFindRecord('profile').returns({id: profileId});

    let newRecord = run(() => store.createRecord('profile', {description: 'foo'}));
    let newProfile = await run(() => newRecord.save());
    let foundRecord = await run(() => store.findRecord('profile', profileId));

    assert.deepEqual(foundRecord, newProfile);
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
test("failure with fails method when passing model instance as parameter and no returns is used", function(assert) {
    let done = assert.async();

    let profile = make('profile');
    let mock = mockFindRecord(profile).fails();
    run(() => {
      FactoryGuy.store.findRecord('profile', profile.id, {reload: true})
                .catch(() => {
                  assert.equal(mock.timesCalled, 1, 'mock called once');
                  assert.equal(mock.status, 500, 'stats 500');
                  done();
                });
    });
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
run(() => {
      let done = assert.async();
      let mock = mockFindRecord('profile', {description: 'dude'});
      let profileId = mock.get('id');

      FactoryGuy.store.findRecord('profile', profileId).then(function(profile) {
        assert.ok(profile.get('description') === 'dude');
        done();
      });
    });
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
run(() => {
        let done = assert.async();

        let hat1 = build('big-hat');
        let hat2 = build('big-hat');
        let json = build('user', {hats: [hat1, hat2]});

        mockFindRecord('user').returns({json});

        FactoryGuy.store.findRecord('user', json.get('id')).then(function(user) {
          assert.ok(user.get('hats.firstObject.id') === hat1.get('id') + '');
          assert.ok(user.get('hats.lastObject.id') === hat2.get('id') + '');
          done();
        });
      });
    });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
return run(async () => {
      let cat = make('cat', {type: 'Cutest'});
      let mock = mockFindRecord('cat').returns({model: cat});

      let catA = await FactoryGuy.store.findRecord('cat', mock.get('id'), {reload: true});
      assert.equal(catA.get('type'), 'Cutest');
    });
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
run(() => {
        let done = assert.async();
        let user = mockFindRecord('user', 'with_hats');
        let userId = user.get('id');

        FactoryGuy.store.findRecord('user', userId).then(function(user) {
          assert.ok(user.get('hats.length') === 2);
          assert.ok(user.get('hats.firstObject.type') === 'BigHat');
          done();
        });
      });
    });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
return run(async () => {
      let cat  = make('cat'),
          mock = mockFindRecord(cat);

      let catA = await FactoryGuy.store.findRecord('cat', mock.get('id'), {reload: true});
      assert.deepEqual(catA, cat);
    });
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
return run(async () => {
      let cat  = make('cat'),
          mock = mockFindRecord(cat);

      let catA = await FactoryGuy.store.findRecord('cat', mock.get('id'), {reload: true});
      assert.deepEqual(catA, cat);
    });
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
run(() => {
        let done = assert.async();
        let profile = mockFindRecord('profile', 'with_company', 'with_bat_man');
        let profileId = profile.get('id');

        FactoryGuy.store.findRecord('profile', profileId).then(function(profile) {
          assert.ok(profile.get('company.name') === 'Silly corp');
          assert.ok(profile.get('superHero.name') === 'BatMan');
          done();
        });
      });
    });