How to use the jest-fetch-mock.mock.calls function in jest-fetch-mock

To help you get started, we’ve selected a few jest-fetch-mock 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 BlueBrain / nexus-js / src / Organization / __tests__ / Organization.spec.ts View on Github external
it('set the rev option', async () => {
      await getOrganization('myorg', { rev: 12 });
      expect(mock.calls[0][0]).toEqual(`${baseUrl}/orgs/myorg?rev=12`);
    });
  });
github BlueBrain / nexus-js / src / Schema / __tests__ / Schema.spec.ts View on Github external
it('should tag the schema', async () => {
      await tagSchema('myorg', 'mylabel', 'myschema', 3, {
        tagName: 'mytag',
        tagFromRev: 2,
      });

      expect(mock.calls[0][0]).toEqual(
        `${baseUrl}/schemas/myorg/mylabel/myschema/tags?rev=3`,
      );
      expect(mock.calls[0][1].method).toEqual('POST');
      expect(mock.calls[0][1].body).toEqual(
        JSON.stringify({ tag: 'mytag', rev: 2 }),
      );
    });
  });
github BlueBrain / nexus-js / src / Realm / __tests__ / Realm.spec.ts View on Github external
it('should make a GET request using the realmLabel', async () => {
      await getRealm('myrealm');
      expect(mock.calls[0][0]).toEqual(`${baseUrl}/realms/myrealm`);
    });
    it('should make a GET request using the realmLabel and specific rev', async () => {
github BlueBrain / nexus-js / src / __tests__ / Nexus.spec.ts View on Github external
it('should return an organisation', async () => {
      mockResponses([JSON.stringify(mockOrgResponse)]);
      const org: Organization = await nexus.getOrganization('myorg');
      expect(mock.calls.length).toBe(1);
      expect(org).toBeInstanceOf(Organization);
      expect(org.label).toEqual('myorg');
    });
  });
github BlueBrain / nexus-js / src / Project / __tests__ / Project.spec.ts View on Github external
it('should call the expected URL with rev and payload', async () => {
      const projectOptions = {
        base: 'http://base.com',
        name: 'This is top secret',
        prefixMappings: [
          {
            prefix: 'name',
            namespace: 'http://schema.org/name',
          },
        ],
      };
      await updateProject('myorg', 'topsecret', 12, projectOptions);
      expect(mock.calls[0][0]).toEqual(
        `${baseUrl}/projects/myorg/topsecret?rev=12`,
      );
      expect(mock.calls[0][1].body).toEqual(JSON.stringify(projectOptions));
    });
    it('should only pass the required fields (name)', async () => {
github BlueBrain / nexus-js / src / View / SparqlView / __tests__ / SparqlView.spec.ts View on Github external
it('should query the Sparql view', async () => {
      mockResponses([JSON.stringify(mockSparlQueryResponse)]);
      const result: SparqlViewQueryResponse = await view.query(
        'SELECT * where {?s ?p ?o} LIMIT 3',
      );
      expect(mock.calls.length).toBe(1);
      expect(result.head.vars.length).toBe(3);
    });
  });
github BlueBrain / nexus-js / src / File / __tests__ / file.spec.ts View on Github external
it('should POST the new file with the expected payload', async () => {
      mockResponse(JSON.stringify(mockFileResponse), { status: 200 });
      const buffer = new Buffer('abc');
      const stream = new Readable();
      stream.push(buffer);
      stream.push(null);

      await NexusFile.create('myOrg', 'myProject', stream);
      const body = mock.calls[0][1].body;
      expect(body._overheadLength).toBe(143);
    });
  });
github BlueBrain / nexus-js / src / Resource / __tests__ / Resource.spec.ts View on Github external
it('should call httpGet method with the proper get views url for expanded', async () => {
      const r: Resource = await getResource(
        'myorg',
        'myproject',
        'myschema',
        'myresource',
        { expanded: true },
      );
      expect(mock.calls[0][0]).toEqual(
        `${baseUrl}/resources/myorg/myproject/myschema/myresource?format=expanded`,
      );
      expect(r).toBeInstanceOf(Resource);
      expect(r).toHaveProperty('expanded', true);
    });
  });
github BlueBrain / nexus-js / src / ACL / __tests__ / ACL.spec.ts View on Github external
it('should return a list of Identities', async () => {
        const indetities = await listIdentities();
        expect(mock.calls[0][0]).toEqual(`${baseUrl}/identities`);
        expect(indetities).toMatchSnapshot();
      });
    });
github BlueBrain / nexus-js / src / View / ElasticSearchView / __tests__ / ElasticSearchView.spec.ts View on Github external
term: {
                  '@type':
                    'https://bbp-nexus.epfl.ch/vocabs/bbp/neurosciencegraph/core/v0.1.0/Person',
                },
              },
              {
                term: {
                  '@type': 'somethingElse',
                },
              },
            ],
          },
        },
      };
      expect(mock.calls[0][0]).toEqual(baseUrl + view.queryURL);
      expect(mock.calls[0][1].body).toEqual(JSON.stringify(expectedQuery));
    });
  });