How to use the node-fetch.mockResolvedValue function in node-fetch

To help you get started, we’ve selected a few node-fetch 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 MichaelDeBoey / gatsby-remark-embedder / src / __tests__ / transformers / Twitter.js View on Github external
const mockFetch = html =>
  fetchMock.mockResolvedValue({ json: () => Promise.resolve({ html }) });
github SelfKeyFoundation / Identity-Wallet / src / main / exchanges / exchanges-service.spec.js View on Github external
it('loadExchangeData', async () => {
		fetch.mockResolvedValue({
			json() {
				return { entities: exchanges };
			}
		});
		let stub = sinon.stub(Exchange, 'import');
		await service.loadExchangeData();
		expect(stub.getCall(0).args[0]).toEqual(importExchanges);
	});
});
github SelfKeyFoundation / Identity-Wallet / src / main / identity / id-attribute-type-service.spec.js View on Github external
it('loadIdAttributeTypes', async () => {
		fetch.mockResolvedValue({
			json() {
				return { ID_Attributes: idAttributesTypes };
			}
		});
		let stub = sinon.stub(IdAttributeType, 'import');
		await service.loadIdAttributeTypes();
		expect(stub.getCall(0).args[0]).toEqual(importIdAttributeTypes);
	});
	it('resolveSchemas', async () => {
github SelfKeyFoundation / Identity-Wallet / src / main / identity / repository.spec.js View on Github external
it('loadRemote', async () => {
		let testRepo = {
			name: 'test',
			idAttributes: []
		};
		let testUrl = 'https://test-url/repository.json';
		fetch.mockResolvedValue({
			status: 200,
			json() {
				return testRepo;
			}
		});
		let res = await Repository.loadRemote(testUrl);

		expect(res.url).toBe(testUrl);
		expect(res.content).toEqual(testRepo);
		expect(res.name).toEqual(testRepo.name);
	});
github SelfKeyFoundation / Identity-Wallet / src / main / token / price-service.spec.js View on Github external
it('loadPriceData', async () => {
		const priceService = new PriceService();
		let addStub = sinon.stub(TokenPrice, 'bulkAdd').resolves();
		let editStub = sinon.stub(TokenPrice, 'bulkEdit').resolves();
		sinon.stub(TokenPrice, 'findAll').resolves(existingPrices);
		fetch.mockResolvedValue({
			json() {
				return externalPrices;
			}
		});
		await priceService.loadPriceData();
		expect(editStub.getCall(0).args).toEqual([toUpdate]);
		expect(addStub.getCall(0).args).toEqual([toInsert]);
	});
	it('startUpdateData', async () => {
github SelfKeyFoundation / Identity-Wallet / src / main / identity / ui-schema.spec.js View on Github external
it('loadRemote', async () => {
		let testScchema = {
			test: 'test'
		};
		let testUrl = 'https://test-url/ui-schema.json';
		fetch.mockResolvedValue({
			status: 200,
			json() {
				return testScchema;
			}
		});
		let res = await UiSchema.loadRemote(testUrl);

		expect(res.url).toBe(testUrl);
		expect(res.content).toEqual(testScchema);
	});
github SelfKeyFoundation / Identity-Wallet / src / main / blockchain / staking-service.spec.js View on Github external
beforeEach(() => {
		service = new StakingService({ web3Service: web3ServiceMock });
		fetch.mockResolvedValue({
			json() {
				return remoteConfig;
			}
		});
	});
	afterEach(() => {