-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,84 @@ | ||
import { expect } from "chai"; | ||
import sinon from "sinon"; | ||
import { expect } from "chai" | ||
import sinon from "sinon" | ||
|
||
import * as graphql from "graphql"; | ||
import { buildSchema } from "#/helpers/schema.helper"; | ||
import { context } from "#/helpers/server.helper"; | ||
import BigInt from "graphql-bigint"; | ||
import * as graphql from "graphql" | ||
import { buildSchema } from "#/helpers/schema.helper" | ||
import { context } from "#/helpers/server.helper" | ||
import BigInt from "graphql-bigint" | ||
|
||
describe("Enclosure Graph Object", () => { | ||
const schema = buildSchema(); | ||
const enclosureFields = schema.getType("Enclosure").getFields(); | ||
const schema = buildSchema() | ||
const enclosureFields = schema.getType("Enclosure").getFields() | ||
|
||
const enclosureObject = { | ||
item: { _slugs: ["toto", "tata"], feed: { identifier: "blog-de-toto" } }, | ||
duration_in_seconds: 600, | ||
length: "123521", | ||
mime_type: "audio/mpeg", | ||
meta_url: { | ||
path: "http://anurl.test/afile.mp3" | ||
path: "http://anurl.test/afile.mp3?p=f" | ||
} | ||
}; | ||
} | ||
|
||
it("should include a required int duration", () => { | ||
expect(enclosureFields).to.have.property("duration"); | ||
expect(enclosureFields).to.have.property("duration") | ||
expect(enclosureFields.duration.type).to.deep.equals( | ||
new graphql.GraphQLNonNull(graphql.GraphQLInt) | ||
); | ||
}); | ||
) | ||
}) | ||
|
||
it("should resolve duration", () => { | ||
enclosureObject.duration_in_seconds = 600; | ||
expect(enclosureFields.duration.resolve(enclosureObject)).to.equals(600); | ||
enclosureObject.duration_in_seconds = -1; | ||
expect(enclosureFields.duration.resolve(enclosureObject)).to.equals(0); | ||
enclosureObject.duration_in_seconds = null; | ||
expect(enclosureFields.duration.resolve(enclosureObject)).to.equals(0); | ||
delete enclosureObject.duration_in_seconds; | ||
expect(enclosureFields.duration.resolve(enclosureObject)).to.equals(0); | ||
}); | ||
enclosureObject.duration_in_seconds = 600 | ||
expect(enclosureFields.duration.resolve(enclosureObject)).to.equals(600) | ||
enclosureObject.duration_in_seconds = -1 | ||
expect(enclosureFields.duration.resolve(enclosureObject)).to.equals(0) | ||
enclosureObject.duration_in_seconds = null | ||
expect(enclosureFields.duration.resolve(enclosureObject)).to.equals(0) | ||
delete enclosureObject.duration_in_seconds | ||
expect(enclosureFields.duration.resolve(enclosureObject)).to.equals(0) | ||
}) | ||
|
||
it("should include a required bigint size", () => { | ||
expect(enclosureFields).to.have.property("size"); | ||
expect(enclosureFields).to.have.property("size") | ||
expect(enclosureFields.size.type).to.deep.equals( | ||
new graphql.GraphQLNonNull(BigInt) | ||
); | ||
}); | ||
) | ||
}) | ||
|
||
it("should resolve size", () => { | ||
expect(enclosureFields.size.resolve(enclosureObject)).to.equals(123521); | ||
const five_tera = 5 * 1024 * 1024 * 1024 * 1024 * 1024; | ||
expect(enclosureFields.size.resolve(enclosureObject)).to.equals(123521) | ||
const five_tera = 5 * 1024 * 1024 * 1024 * 1024 * 1024 | ||
expect( | ||
enclosureFields.size.resolve({ | ||
...enclosureObject, | ||
length: "" + five_tera /* 5 To */ | ||
}) | ||
).to.equals(five_tera); | ||
}); | ||
).to.equals(five_tera) | ||
}) | ||
|
||
it("should include a required string type", () => { | ||
expect(enclosureFields).to.have.property("type"); | ||
expect(enclosureFields).to.have.property("type") | ||
expect(enclosureFields.type.type).to.deep.equals( | ||
new graphql.GraphQLNonNull(graphql.GraphQLString) | ||
); | ||
}); | ||
) | ||
}) | ||
|
||
it("should resolve type", () => { | ||
expect(enclosureFields.type.resolve(enclosureObject)).to.equals( | ||
"audio/mpeg" | ||
); | ||
}); | ||
) | ||
}) | ||
|
||
it("should include a required string url", () => { | ||
expect(enclosureFields).to.have.property("url"); | ||
expect(enclosureFields).to.have.property("url") | ||
expect(enclosureFields.url.type).to.deep.equals( | ||
new graphql.GraphQLNonNull(graphql.GraphQLString) | ||
); | ||
}); | ||
) | ||
}) | ||
|
||
it("should resolve url", () => { | ||
expect(enclosureFields.url.resolve(enclosureObject, {}, context)).to.equals( | ||
"http://" + context.hosts.stats + "/blog-de-toto/tata/enclosure.mp3?p=f" | ||
); | ||
}); | ||
}); | ||
) | ||
}) | ||
}) |