Skip to content

Commit 0cf34db

Browse files
authored
Merge pull request #28 from hypercerts-org/fix/formatter
MIME type validation formattes
2 parents fcec287 + 3b4435a commit 0cf34db

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

Diff for: src/validator/validators/PropertyValidator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface GeoJSONProperty {
1818
}
1919

2020
class GeoJSONValidationStrategy implements PropertyValidationStrategy {
21-
private readonly MIME_TYPE = "applications/geo+json";
21+
private readonly MIME_TYPE = "application/geo+json";
2222

2323
validate(property: NonNullable<PropertyValue>): ValidationError[] {
2424
if (!this.isGeoJSONProperty(property)) {

Diff for: test/utils/formatter.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ const testData: Partial<TestDataType> = {
2020
properties: [
2121
{ trait_type: "test trait type", value: "aaa" },
2222
{ trait_type: "test trait type", type: "image", src: "https://example.com", name: "test name" },
23+
{
24+
trait_type: "geoJSON",
25+
type: "application/geo+json",
26+
name: "oceanus-conservation-barangay.geojson",
27+
src: "ipfs://bafkreifhfoozmhdtjn2y4xqtosuf26mxr2sxzvrrprkucglgotx3ok362a",
28+
},
2329
],
2430
rights: ["test right 1", "test right 2"],
2531
version: "0.0.1",
@@ -33,6 +39,9 @@ describe("Format Hypercert Data test", () => {
3339
it("checks correct metadata and returns result", () => {
3440
const result = formatHypercertData(testData as TestDataType);
3541

42+
expect(result.valid).to.be.true;
43+
expect(result.data).to.not.be.null;
44+
3645
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
3746
const validKeys = Object.keys(result.data!);
3847

Diff for: test/validator/validators/MetadataValidator.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe("MetadataValidator", () => {
7474
},
7575
{
7676
trait_type: "geoJSON",
77-
type: "applications/geo+json",
77+
type: "application/geo+json",
7878
src: "ipfs://QmExample",
7979
name: "location.geojson",
8080
},
@@ -164,7 +164,7 @@ describe("MetadataValidator", () => {
164164
},
165165
{
166166
trait_type: "geoJSON",
167-
type: "applications/geo+json",
167+
type: "application/geo+json",
168168
src: "ipfs://QmExample",
169169
name: "location.geojson",
170170
},

Diff for: test/validator/validators/PropertyValidator.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe("PropertyValidator", () => {
3232
it("should validate a valid geoJSON property", () => {
3333
const property = {
3434
trait_type: "geoJSON",
35-
type: "applications/geo+json",
35+
type: "application/geo+json",
3636
src: "ipfs://QmExample",
3737
name: "location.geojson",
3838
};
@@ -45,7 +45,7 @@ describe("PropertyValidator", () => {
4545
it("should accept HTTPS source", () => {
4646
const property = {
4747
trait_type: "geoJSON",
48-
type: "applications/geo+json",
48+
type: "application/geo+json",
4949
src: "https://example.com/location.geojson",
5050
name: "location.geojson",
5151
};
@@ -67,14 +67,14 @@ describe("PropertyValidator", () => {
6767
expect(result.errors).to.deep.include({
6868
field: "type",
6969
code: "invalid_mime_type",
70-
message: "GeoJSON type must be applications/geo+json",
70+
message: "GeoJSON type must be application/geo+json",
7171
});
7272
});
7373

7474
it("should reject invalid source URL", () => {
7575
const property = {
7676
trait_type: "geoJSON",
77-
type: "applications/geo+json",
77+
type: "application/geo+json",
7878
src: "invalid://QmExample",
7979
name: "location.geojson",
8080
};
@@ -91,7 +91,7 @@ describe("PropertyValidator", () => {
9191
it("should reject invalid file extension", () => {
9292
const property = {
9393
trait_type: "geoJSON",
94-
type: "applications/geo+json",
94+
type: "application/geo+json",
9595
src: "ipfs://QmExample",
9696
name: "location.wrong",
9797
};

Diff for: vitest.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default defineConfig({
1010
// If you want a coverage reports even if your tests are failing, include the reportOnFailure option
1111
reportOnFailure: true,
1212
thresholds: {
13-
lines: 73,
13+
lines: 77,
1414
branches: 84,
1515
functions: 76,
1616
statements: 77,

0 commit comments

Comments
 (0)