JSassCompiler implements SassCompiler { @Override public String compileFile(String inputFileName, String includeDirName) throws JSassCompilerException { return compileFile(inputFileName, includeDirName, false, ""); } JSassCompiler();  JSassCompiler(int precision);  JSassCompiler(int precision, String tmpDirName); @Override String compileFile(String inputFileName, String includeDirName); @Override String compileFile(
			String inputFileName, String includeDirName,
			boolean generateSourceMap); @Override String compileFile(
			String inputFileName, String includeDirName,
			boolean generateSourceMap, String sourceMapFileName); @Override String compileString(String input, String includeDirName); @Override String compileString(
			String input, String inputFileName, String includeDirName,
			boolean generateSourceMap); @Override String compileString(
			String input, String inputFileName, String includeDirName,
			boolean generateSourceMap, String sourceMapFileName);  }
@Test public void testCompileFileClayCss() throws Exception { try (SassCompiler sassCompiler = new JSassCompiler()) { File clayCssDir = new File( "../sass-compiler-jni/test-classes/unit/com/liferay/sass" + "/compiler/jni/internal/dependencies/clay-css"); for (File inputFile : clayCssDir.listFiles()) { if (inputFile.isDirectory()) { continue; } String fileName = inputFile.getName(); if (fileName.startsWith("_") || !fileName.endsWith("scss")) { continue; } String actualOutput = sassCompiler.compileFile( inputFile.getCanonicalPath(), "", true); Assert.assertNotNull("Testing: " + fileName, actualOutput); String expectedOutputFileName = "expected" + File.separator + fileName.replace("scss", "css"); File expectedOutputFile = new File( clayCssDir, expectedOutputFileName); if (expectedOutputFile.exists()) { String expectedOutput = read(expectedOutputFile.toPath()); Assert.assertEquals( "Testing: " + fileName, stripNewLines(expectedOutput), stripNewLines(actualOutput)); } } } }
@Test public void testCompileFileSassSpec() throws Exception { try (SassCompiler sassCompiler = new JSassCompiler()) { File sassSpecDir = new File( "../sass-compiler-jni/test-classes/unit/com/liferay/sass" + "/compiler/jni/internal/dependencies/sass-spec"); for (File testDir : sassSpecDir.listFiles()) { File inputFile = new File(testDir, "input.scss"); String dirName = testDir.getName(); if (!inputFile.exists() || dirName.endsWith("-4.0")) { continue; } String actualOutput = sassCompiler.compileFile( inputFile.getCanonicalPath(), "", false); Assert.assertNotNull("Testing: " + dirName, actualOutput); File expectedOutputFile = new File( testDir, "expected_output.css"); String expectedOutput = read(expectedOutputFile.toPath()); Assert.assertEquals( "Testing: " + dirName, stripNewLines(expectedOutput), stripNewLines(actualOutput)); } } }
@Test public void testCompileFileSassVariableWithUnicode() throws Exception { try (SassCompiler sassCompiler = new JSassCompiler()) { File inputDir = new File( "../sass-compiler-jni/test-classes/unit/com/liferay/sass" + "/compiler/jni/internal/dependencies/"); File inputFile = new File(inputDir, "/unicode/input.scss"); String actualOutput = sassCompiler.compileFile( inputFile.getCanonicalPath(), ""); Assert.assertNotNull(actualOutput); File expectedOutputFile = new File( inputDir, "/unicode/expected_output.css"); String expectedOutput = read(expectedOutputFile.toPath()); Assert.assertEquals( stripNewLines(expectedOutput), stripNewLines(actualOutput)); } }
@Test public void testCompileFileWithSourceMap() throws Exception { try (SassCompiler sassCompiler = new JSassCompiler()) { File inputDir = new File( "../sass-compiler-jni/test-classes/unit/com/liferay/sass" + "/compiler/jni/internal/dependencies/sass-spec/14_imports"); File sourceMapFile = new File( inputDir, ".sass-cache/input.css.map"); sourceMapFile.deleteOnExit(); Assert.assertFalse(sourceMapFile.exists()); File inputFile = new File(inputDir, "input.scss"); String actualOutput = sassCompiler.compileFile( inputFile.getCanonicalPath(), "", true, sourceMapFile.getCanonicalPath()); Assert.assertNotNull(actualOutput); Assert.assertTrue(sourceMapFile.exists()); File expectedOutputFile = new File( "../sass-compiler-jni/test-classes/unit/com/liferay/sass" + "/compiler/jni/internal/dependencies/sourcemap", "expected_output_custom_source_map.css"); String expectedOutput = read(expectedOutputFile.toPath()); Assert.assertEquals( stripNewLines(expectedOutput), stripNewLines(actualOutput)); } }