Object become empty in flushed object inside test
See original GitHub issueDescribe the bug
When running tests not empty objects replaced with empty objects. From what I tested it seems the use of an array causes this.
To Reproduce Steps to reproduce the behavior:
Run the test below.
import { TestBed } from '@angular/core/testing';
import {
ApolloTestingModule,
ApolloTestingController,
} from 'apollo-angular/testing';
import { Apollo, gql } from 'apollo-angular';
describe('UndefinedSpec', () => {
let controller: ApolloTestingController;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [ApolloTestingModule]
});
controller = TestBed.inject(ApolloTestingController);
});
afterEach(() => {
// After every test, assert that there are no more pending requests.
controller.verify();
});
it('undefined', (done) => {
const apollo = TestBed.inject(Apollo);
const TEST_QUERY = gql`
query testQuery {
responseEntity {
body { ...TestObjFragment }
}
}
fragment TestObjFragment on TestObj {
id
}
`;
apollo.watchQuery({
query: TEST_QUERY,
}).valueChanges.subscribe(result => {
const data = result.data as any;
expect(data.responseEntity.body[0]).toBeTruthy();
expect(data.responseEntity.body[0]).not.toEqual({});
expect(data.responseEntity.body[0].id).toEqual(1);
done();
});
const op = controller.expectOne('testQuery');
op.flush({
data: { responseEntity: { body: [ { id: 1, } ], }, },
});
});
});
Expected behavior
Test should pass.
Environment:
@apollo/client
:3.3.7
apollo-angular
:2.2.0
graphql
:15.5.0
@angular/core
:10.1.6
@angular/cli
:10.1.7
typescript
:4.0.5
Additional context
The same definition works just fine in the browser.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
How do I test for an empty JavaScript object? - Stack Overflow
function isEmpty(obj) { for(var prop in obj) { if(Object.prototype. ... Tested under Node, Chrome, Firefox and IE 9, it becomes evident that for...
Read more >How to Check if an Object is Empty in JavaScript – JS Java ...
If it returns zero (0), the object is empty. You can now use this method to check if an object is empty with...
Read more >Testing With Mock Objects - ScalaTest
Testing with mock objects. You can use any Java mocking framework with ScalaTest, or ScalaMock, a Scala mocking alternative. ScalaTest provides just enough ......
Read more >Emptying a bucket - Amazon Simple Storage Service
When you empty a bucket, you delete all the objects, but you keep the bucket. After you empty a bucket, it cannot be...
Read more >Testing tools - Django documentation
Makes a GET request on the provided path and returns a Response object, ... is that some database behaviors cannot be tested within...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My bad I forgot to add
__typename
.@Urigo I’d love to, but unfortunately I’m too busy this week