import {compareTranspiled} from "./helpers";

describe('require', () => {
	test('should change relative path', () => {
		const options = {
			redirect: {
				"/examples(/\\w+)*/lib\\.js$" : "./examples/require/different/lib"
			}
		};
		
		return compareTranspiled("examples/require/relative.js", options);
	});
	
	test('should change relative path dynamically', () => {
		const options = {
			redirect: {
				"/examples(?:/\\w+)*/(\\w+)\\.js$" : "./examples/require/different/$1"
			}
		};
		
		return compareTranspiled("examples/require/relative.js", options);
	});
	
	test('should change path from a node module to relative', () => {
		const options = {
			redirect: {
				"node_module" : "./examples/require/different/lib.js"
			}
		};
		
		return compareTranspiled("examples/require/module.js", options);
	});
	
	test('should dynamically change path from a node module to relative', () => {
		const options = {
			redirect: {
				"node_module/(\\w+)\\.js$" : "./examples/require/different/$1"
			}
		};
		
		return compareTranspiled("examples/require/moduleRelative.js", options);
	});
	
	test('should change path from a node module to a different node module', () => {
		const options = {
			redirect: {
				"node_module" : "different_node_module"
			},
			root: "./examples"
		};
		
		return compareTranspiled("examples/require/module2module.js", options);
	});
	
	test('should dynamically change path from a node module to a different node module', () => {
		const options = {
			redirect: {
				"node_module/([\\w.]+)$" : "different_node_module/$1"
			},
			root: "./examples"
		};
		
		return compareTranspiled("examples/require/module2moduleRelative.js", options);
	});
	
	test('should change path from relative to a node module', () => {
		const options = {
			redirect: {
				"/examples(/\\w+)*/lib\\.js$" : "node_module"
			},
			root: "./examples"
		};
		
		return compareTranspiled("examples/require/relative2module.js", options);
	});
	
	test('should dynamically change path from relative to a node module', () => {
		const options = {
			redirect: {
				"/examples(?:/\\w+)*/(\\w+)\\.js$" : "node_module/$1"
			},
			root: "./examples"
		};
		
		return compareTranspiled("examples/require/relative2moduleDyn.js", options);
	});
});
@@ -2239,11 +2239,269 @@
 );%0A%09%7D);%0A
+%09%0A%09test.only('should not change when no matching redirect is found', () =%3E %7B%0A%09%09const options = %7B%0A%09%09%09redirect: %7B%0A%09%09%09%09%22path/wont/match$%22 : %22./examples/require/different/lib%22%0A%09%09%09%7D%0A%09%09%7D;%0A%09%09%0A%09%09return compareTranspiled(%22examples/require/noMatch.js%22, options);%0A%09%7D);%0A
 %7D);

Add test for no match