test('Adding a record to the memory source immediately pushes the update to the remote', async function(assert) {
      assert.expect(1);

      await coordinator.activate();

      let planet: Record = {
        type: 'planet',
        id: schema.generateId(),
        attributes: { name: 'Jupiter', classification: 'gas giant' }
      };

      fetchStub.withArgs('/planets').returns(
        jsonapiResponse(201, {
          data: {
            id: planet.id,
            type: 'planets',
            attributes: { name: 'Jupiter', classification: 'gas giant' }
          }
        })
      );

      await memory.update(t => t.addRecord(planet));

      let result = memory.cache.query(q => q.findRecord(planet));

      assert.deepEqual(result, {
        type: 'planet',
        id: planet.id,
        attributes: { name: 'Jupiter', classification: 'gas giant' }
      });
    });
  test('Adding a record to the memory source queues an update request which will be pushed to the remote', async function(assert) {
    assert.expect(2);

    await coordinator.activate();

    fetchStub.withArgs('/planets').returns(
      jsonapiResponse(201, {
        data: {
          id: '12345',
          type: 'planets',
          attributes: { name: 'Jupiter', classification: 'gas giant' }
        }
      })
    );

    let planet: Record = {
      type: 'planet',
      id: schema.generateId(),
      attributes: { name: 'Jupiter', classification: 'gas giant' }
    };
    await memory.update(t => t.addRecord(planet));

    assert.deepEqual(
      memory.cache.query(q => q.findRecord(planet)),
      {
        type: 'planet',
        id: planet.id,
        attributes: { name: 'Jupiter', classification: 'gas giant' }
      },
      'keys have not been syncd up yet - remote source still needs to process request'
    );

    await remote.requestQueue.process();

    assert.deepEqual(
      memory.cache.query(q => q.findRecord(planet)),
      {
        type: 'planet',
        id: planet.id,
        keys: { remoteId: '12345' },
        attributes: { name: 'Jupiter', classification: 'gas giant' }
      },
      'keys are syncd up after remote source finishes processing requests'
    );
  });
    test('Adding a record to the memory source immediately pushes the update to the remote', async function(assert) {
      assert.expect(3);

      await coordinator.activate();

      fetchStub.withArgs('/planets').returns(
        jsonapiResponse(201, {
          data: {
            id: '12345',
            type: 'planets',
            attributes: { name: 'Jupiter', classification: 'gas giant' }
          }
        })
      );

      let planet: Record = {
        type: 'planet',
        id: schema.generateId(),
        attributes: { name: 'Jupiter', classification: 'gas giant' }
      };
      await memory.update(t => t.addRecord(planet));

      let result = memory.cache.query(q => q.findRecord(planet));

      assert.deepEqual(result, {
        type: 'planet',
        id: planet.id,
        keys: { remoteId: '12345' },
        attributes: { name: 'Jupiter', classification: 'gas giant' }
      });

      assert.equal(
        keyMap.idToKey('planet', 'remoteId', planet.id),
        '12345',
        'id mapped to key'
      );
      assert.equal(
        keyMap.keyToId('planet', 'remoteId', '12345'),
        planet.id,
        'key mapped to id'
      );
    });