it('should map to entities with empty object', () => { let entity = getHydrator().fromSchema({ name: 'foo', }, {}); assert.notProperty(entity, 'name'); });
it('should not map invalid value to entities', () => { let entity = getHydrator().fromSchema({ bar: 'foo', }, User); assert.notProperty(entity, 'bar'); });
.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'); });
.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); });
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, ); });
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, ); });
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(); }, }); });
return handle.result().then((result) => { assert.equal(result.data['luke'].name, 'Luke Skywalker'); assert.notProperty(result.data, 'vader'); });