How to use mwp-test-utils - 4 common examples

To help you get started, we’ve selected a few mwp-test-utils 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 meetup / meetup-web-platform / tests / integration / render.int.js View on Github external
it('renders the expected app content for nested path of mock app route config', () => {
		return start(getMockRenderRequestMap(), {}).then(server => {
			const request = {
				method: 'get',
				url: '/foo/bar?heyhey=true',
				credentials: 'whatever',
			};
			return server
				.inject(request)
				.then(response => {
					expect(response.payload).toContain(fooPathContent);
					expect(response.payload).not.toContain(ROOT_INDEX_CONTENT);
					expect(response.payload).toContain(fakeApiProxyResponse);
					expect(
						response.headers['set-cookie'].find(h =>
							h.startsWith('x-mwp-csrf-header')
						)
					).not.toBeUndefined();
github meetup / meetup-web-platform / tests / integration / sideEffect.int.js View on Github external
const testSideEffectError = (Component, name) =>
	start(getMockRenderRequestMap(), {}).then(server => {
		const request = {
			method: 'get',
			url: `/badImplementation?${name}`,
			credentials: 'whatever',
		};
		return server
			.inject(request)
			.then(response => {
				expect(response.statusCode === 500);
				expect(Component.rewind).toHaveBeenCalled();
			})
			.then(() => server.stop())
			.catch(err => {
				server.stop();
				throw err;
			});
github meetup / meetup-web-platform / tests / integration / requestAuthPlugin.int.js View on Github external
});
		}
		if (url.includes(serverConfig.oauth.access_url)) {
			return makeMockFetchResponse({
				oauth_token: expectedOauthToken,
				refresh_token: 'whatever',
			});
		}
		return makeMockFetchResponse({});
	});
	const fooRoute = {
		method: 'get',
		path: '/foo',
		handler: (request, reply) => reply(expectedResponse),
	};
	const server = getServer();
	return server
		.register({
			register: requestAuthPlugin,
			options: serverConfig,
		})
		.then(() => server.route(fooRoute))
		.then(() => server.auth.strategy('default', 'oauth', 'required'))
		.then(() => server.inject(makeRequest(cookies)))
		.then(test)
		.then(() => server.stop());
};
github meetup / meetup-web-platform / tests / integration / api.int.js View on Github external
const csrfHeaders = () =>
			getCsrfHeaders().then(([cookieToken, headerToken]) => [cookieToken, '']);

mwp-test-utils

Helpers for running unit tests in MWP apps

MIT
Latest version published 2 years ago

Package Health Score

39 / 100
Full package analysis

Similar packages