Пример #1
0
    it('should map to entities with empty object', () => {
      let entity = getHydrator().fromSchema({
        name: 'foo',
      }, {});

      assert.notProperty(entity, 'name');
    });
Пример #2
0
    it('should not map invalid value to entities', () => {
      let entity = getHydrator().fromSchema({
        bar: 'foo',
      }, User);

      assert.notProperty(entity, 'bar');
    });
Пример #3
0
      .then((newResult: any) => {
        // There should be one fewer todo item than before
        assert.equal(newResult.data.todoList.todos.length, 2);

        // The item shouldn't be in the store anymore
        assert.notProperty(client.queryManager.getApolloState().data, 'Todo3');
      });
Пример #4
0
      .then((newResult: any) => {
        // There should be one fewer todo item than before
        assert.equal(newResult.data.todoList.todos.length, 2);

        // The item shouldn't be in the store anymore
        assert.notProperty(client.queryManager.getApolloState().data, 'Todo3');
        // shouldn't have affected other data elements
        assert.notEqual(client.queryManager.getApolloState().data['TodoList5']['__typename'], undefined);
      });
Пример #5
0
 p.then(() => {
   assert.lengthOf(fetchMock.calls(url), 1);
   assert.lengthOf(_.keys(state), 2);
   assert.equal(state[uiKey1].state, uidata.UIDataState.LOADING);
   assert.equal(state[uiKey2].state, uidata.UIDataState.LOADING);
   assert.isUndefined(state[uiKey1].data);
   assert.isUndefined(state[uiKey2].data);
   assert.notProperty(state[uiKey1], "data");
   assert.notProperty(state[uiKey2], "data");
   assert.isUndefined(state[uiKey1].error);
   assert.isUndefined(state[uiKey2].error);
   setTimeout(
     () => {
       assert.equal(state[uiKey1].state, uidata.UIDataState.LOAD_ERROR);
       assert.equal(state[uiKey2].state, uidata.UIDataState.LOAD_ERROR);
       assert.instanceOf(state[uiKey1].error, Error);
       assert.instanceOf(state[uiKey2].error, Error);
       done();
     },
     1000,
   );
 });
Пример #6
0
 p.then(() => {
   assert.lengthOf(fetchMock.calls(`${api.API_PREFIX}/uidata`), 1);
   assert.lengthOf(_.keys(state), 2);
   assert.equal(state[uiKey1].status, uidata.UIDataStatus.SAVING);
   assert.equal(state[uiKey2].status, uidata.UIDataStatus.SAVING);
   assert.isUndefined(state[uiKey1].data);
   assert.isUndefined(state[uiKey2].data);
   assert.notProperty(state[uiKey1], "data");
   assert.notProperty(state[uiKey2], "data");
   assert.isUndefined(state[uiKey1].error);
   assert.isUndefined(state[uiKey2].error);
   setTimeout(
     () => {
       assert.equal(state[uiKey1].status, uidata.UIDataStatus.SAVE_ERROR);
       assert.equal(state[uiKey2].status, uidata.UIDataStatus.SAVE_ERROR);
       assert.instanceOf(state[uiKey1].error, Error);
       assert.instanceOf(state[uiKey2].error, Error);
       done();
     },
     1000,
   );
 });
Пример #7
0
  it('empty error array (handle non-spec-compliant server) #156', (done) => {
    const query = gql`
      query people {
        allPeople(first: 1) {
          people {
            name
          }
        }
      }
    `;

    const networkInterface = mockNetworkInterface(
      {
        request: {query },
        result: {
          data: {
            allPeople: {
              people: {
                name: 'Ada Lovelace',
              },
            },
          },
          errors: [],
        },
      }
    );

    const queryManager = new QueryManager({
      networkInterface,
      store: createApolloStore(),
      reduxRootKey: 'apollo',
    });

    const handle = queryManager.watchQuery({
      query,
    });

    handle.subscribe({
      next(result) {
        assert.equal(result.data['allPeople'].people.name, 'Ada Lovelace');
        assert.notProperty(result, 'errors');
        done();
      },
    });
  });
Пример #8
0
 return handle.result().then((result) => {
   assert.equal(result.data['luke'].name, 'Luke Skywalker');
   assert.notProperty(result.data, 'vader');
 });