Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('set the rev option', async () => {
await getOrganization('myorg', { rev: 12 });
expect(mock.calls[0][0]).toEqual(`${baseUrl}/orgs/myorg?rev=12`);
});
});
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 }),
);
});
});
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 () => {
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');
});
});
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 () => {
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);
});
});
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);
});
});
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);
});
});
it('should return a list of Identities', async () => {
const indetities = await listIdentities();
expect(mock.calls[0][0]).toEqual(`${baseUrl}/identities`);
expect(indetities).toMatchSnapshot();
});
});
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));
});
});