Skip to content

Commit

Permalink
Add test for getExtension method in Embedding class (#1134)
Browse files Browse the repository at this point in the history
- Introduce a new test case to ensure correct behavior of the getExtension method.
- Enhance coverage for the Embedding class, specifically validating its handling of unknown MIME types.

Co-authored-by: Harshpreet Singh <Harshpreet.Singh@dal.ca>
  • Loading branch information
harshpreet08 and harshpreet08 authored Dec 27, 2023
1 parent 7375184 commit bf539ce
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/java/net/masterthought/cucumber/json/EmbeddingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,23 @@ public void getExtension_ReturnsFileExtension() {
assertThat(actualExtension).isEqualTo(this.fileName.split("\\.")[1]);
}

@Test
public void getExtension_UsesExtensionFromNameWhenMIMETypeIsUnknown() {
// Arrange
String mimeType = "unknown/mimetype";
String data = "c29tZSBkYXRh";
String name = "example.docx";

// Creating an embedding here with an unknown MIME type and a name containing a file extension
Embedding embedding = new Embedding(mimeType, data, name);

// Act
String actualExtension = embedding.getExtension();

// Assert
assertThat(actualExtension).isEqualTo("docx");
}

@Test
public void getName_ReturnsNull() {
// given
Expand Down

0 comments on commit bf539ce

Please sign in to comment.