Skip to content

Commit

Permalink
Merge branch 'hotfix/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanni Olivera committed Apr 4, 2018
2 parents 2155fcb + b14f3b3 commit 769b1bb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/schema/types/resolvers/enclosure.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Enclosure = {
"/" +
enclosure.item._slugs[enclosure.item._slugs.length - 1] +
"/enclosure" +
path.extname(enclosure.meta_url.path) +
path.extname(enclosure.meta_url.path).replace(/(.*)\?.*$/, "$1") +
"?p=f"
)
}
Expand Down
80 changes: 40 additions & 40 deletions test/src/schema/types/enclosure.test.js
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"
);
});
});
)
})
})

0 comments on commit 769b1bb

Please sign in to comment.