Skip to content

Commit

Permalink
Merge pull request #1352 from scireum/feature/mbo/OX-10357
Browse files Browse the repository at this point in the history
JUnit: Migrate ApplicationSCSSTest to Kotlin
  • Loading branch information
sabieber authored Jan 8, 2024
2 parents cf6cb92 + c701b97 commit 2d3861e
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 61 deletions.
61 changes: 0 additions & 61 deletions src/test/java/sirius/web/controller/ApplicationSCSSSpec.groovy

This file was deleted.

32 changes: 32 additions & 0 deletions src/test/java/sirius/web/controller/TestGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package sirius.web.controller;

import sirius.kernel.di.std.Part;
import sirius.web.resources.Resource;
import sirius.web.resources.Resources;
import sirius.web.sass.Generator;

import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;

class TestGenerator extends Generator {
@Override
public void warn(String message) {
throw new RuntimeException(message);
}

@Part
private static Resources resources;

@Override
protected InputStream resolveIntoStream(String sheet) throws IOException {
Optional<Resource> res = resources.resolve(sheet);
if (res.isPresent()) {
return res.get().getUrl().openStream();
}
return null;
}

TestGenerator() {
}
}
35 changes: 35 additions & 0 deletions src/test/kotlin/sirius/web/controller/ApplicationSCSSTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - info@scireum.de
*/

package sirius.web.controller

import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import sirius.kernel.SiriusExtension
import sirius.web.sass.Output
import java.io.StringWriter
import kotlin.test.assertTrue

/**
* Tests rendering of application scss.
*/
@ExtendWith(SiriusExtension::class)
class ApplicationSCSSTest {
@Test
fun `application scss can be compiled`() {
val generator = TestGenerator()
generator.importStylesheet("/assets/wondergem/stylesheets/application.scss")
generator.compile()
// Let the content compressor take care of minifying the CSS
val writer = StringWriter()
val output = Output(writer, false)
generator.generate(output)
writer.close()
assertTrue { writer.toString().length > 0 }
}
}

0 comments on commit 2d3861e

Please sign in to comment.