/**
 * `useViewContext` hook tests.
 *
 * Site Kit by Google, Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Internal dependencies
 */
import { renderHook } from '../../../tests/js/test-utils';
import {
	VIEW_CONTEXT_DASHBOARD,
	VIEW_CONTEXT_DASHBOARD_VIEW_ONLY,
} from '../googlesitekit/constants';
import useViewContext from './useViewContext';

describe( 'useViewContext', () => {
	it( 'should not error if no provider is found', () => {
		expect( () => {
			renderHook( () => useViewContext(), {} );
		} ).not.toThrow();

		const { result } = renderHook( () => useViewContext(), {} );

		expect( result.current ).toBe( null );
	} );

	it( 'should return the view context set in the nearest provider', () => {
		const { result } = renderHook( () => useViewContext(), {
			viewContext: VIEW_CONTEXT_DASHBOARD_VIEW_ONLY,
		} );

		expect( result.current ).toBe( VIEW_CONTEXT_DASHBOARD_VIEW_ONLY );
	} );

	const { result: dashboardResult } = renderHook( () => useViewContext(), {
		viewContext: VIEW_CONTEXT_DASHBOARD,
	} );

	expect( dashboardResult.current ).toBe( VIEW_CONTEXT_DASHBOARD );
} );

@@ -1442,23 +1442,123 @@
 ONLY );%0A
-%09%7D );%0A%0A
+%0A%09%09// Return a different view context than above to ensure different%0A%09%09// contexts are returned properly.%0A%09
 %09const %7B
@@ -1589,33 +1589,36 @@
  %7D = renderHook(
- 
+%0A%09%09%09
 () =%3E useViewCon
@@ -1624,19 +1624,24 @@
 ntext(),
- %7B%0A
+%0A%09%09%09%7B%0A%09%09
 %09%09viewCo
@@ -1672,22 +1672,27 @@
 BOARD,%0A%09
-%7D 
+%09%09%7D%0A%09%09
 );%0A%0A
+%09
 %09expect(
@@ -1750,13 +1750,19 @@
 OARD );%0A
+%09%7D );%0A
 %7D );%0A

Add context test into test function.