2022-09-06 09:52:33 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2023-07-31 10:23:49 +00:00
|
|
|
import { TEMPLATES } from '../constants';
|
2022-09-06 09:52:33 +00:00
|
|
|
import { getTemplateDetailsBySlug } from '../utils';
|
|
|
|
|
|
|
|
describe( 'getTemplateDetailsBySlug', function () {
|
|
|
|
it( 'should return single-product object when given an exact match', () => {
|
|
|
|
expect(
|
|
|
|
getTemplateDetailsBySlug( 'single-product', TEMPLATES )
|
|
|
|
).toStrictEqual( TEMPLATES[ 'single-product' ] );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should return single-product object when given a partial match', () => {
|
|
|
|
expect(
|
|
|
|
getTemplateDetailsBySlug( 'single-product-hoodie', TEMPLATES )
|
|
|
|
).toStrictEqual( TEMPLATES[ 'single-product' ] );
|
|
|
|
} );
|
|
|
|
|
2023-07-31 10:23:49 +00:00
|
|
|
it( 'should return taxonomy-product object when given a partial match', () => {
|
|
|
|
expect(
|
|
|
|
getTemplateDetailsBySlug( 'taxonomy-product_tag', TEMPLATES )
|
|
|
|
).toStrictEqual( TEMPLATES[ 'taxonomy-product_tag' ] );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should return taxonomy-product object when given an exact match', () => {
|
|
|
|
expect(
|
|
|
|
getTemplateDetailsBySlug( 'taxonomy-product_brands', TEMPLATES )
|
|
|
|
).toStrictEqual( TEMPLATES[ 'taxonomy-product' ] );
|
|
|
|
} );
|
|
|
|
|
2022-09-06 09:52:33 +00:00
|
|
|
it( 'should return null object when given an incorrect match', () => {
|
|
|
|
expect( getTemplateDetailsBySlug( 'void', TEMPLATES ) ).toBeNull();
|
|
|
|
} );
|
|
|
|
} );
|