Skip to content

Commit cdc0004

Browse files
committed
Tests: refactor create resource without relationship test for new style
I fixed the style of the create resource tests between when #71 was open and when it was merged, so this change brings that test inline with the new style too.
1 parent a8f69a4 commit cdc0004

File tree

1 file changed

+42
-34
lines changed
  • test/integration/create-resource

1 file changed

+42
-34
lines changed

test/integration/create-resource/index.js

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ describe("Creating Resources", () => {
9898
.type("application/vnd.api+json")
9999
.send({"data": ORG_RESOURCE_CLIENT_ID})
100100
.promise()
101-
.then(() => done("Should not run!"), (error) => {
102-
err = error;
103-
done();
104-
});
101+
.then(
102+
() => { done("Should not run!") },
103+
(error) => {
104+
err = error;
105+
done();
106+
}
107+
);
105108
});
106109

107110
describe("HTTP", () => {
@@ -116,40 +119,45 @@ describe("Creating Resources", () => {
116119
});
117120
});
118121
});
119-
});
120122

121-
describe("", () => {
122-
AgentPromise.then((Agent) => {
123-
Agent.request("POST", "/organizations")
124-
.type("application/vnd.api+json")
125-
.send({"data": INVALID_ORG_RESOURCE_NO_DATA_IN_RELATIONSHIP})
126-
.promise()
127-
.then(() => { throw new Error("Should not run!"); }, (err) => {
128-
describe("Creating a Resource With a Missing Relationship Data Key", () => {
129-
describe("HTTP", () => {
130-
it("should return 400", () => {
131-
expect(err.response.status).to.equal(400);
132-
});
133-
});
123+
describe("Creating a Resource With a Missing Relationship Data Key", () => {
124+
let err;
125+
before((done) => {
126+
Agent.request("POST", "/organizations")
127+
.type("application/vnd.api+json")
128+
.send({"data": INVALID_ORG_RESOURCE_NO_DATA_IN_RELATIONSHIP})
129+
.promise()
130+
.then(
131+
() => { done("Should not run!"); },
132+
(error) => {
133+
err = error;
134+
done();
135+
}
136+
);
137+
});
134138

135-
describe("Document Structure", () => {
136-
it("should contain an error", () => {
137-
expect(err.response.body.errors).to.be.an("array");
138-
});
139-
});
139+
describe("HTTP", () => {
140+
it("should return 400", () => {
141+
expect(err.response.status).to.equal(400);
142+
});
143+
});
140144

141-
describe("Error", () => {
142-
it("should have the correct title", () => {
143-
expect(err.response.body.errors[0].title).to.be.equal("Missing relationship linkage.");
144-
});
145+
describe("Document Structure", () => {
146+
it("should contain an error", () => {
147+
expect(err.response.body.errors).to.be.an("array");
148+
});
149+
});
145150

146-
it("should have the correct details", () => {
147-
expect(err.response.body.errors[0].details).to.be.equal("No data was found for the liaisons relationship.");
148-
});
149-
});
150-
});
151-
}).done();
152-
}).done();
151+
describe("The error", () => {
152+
it("should have the correct title", () => {
153+
expect(err.response.body.errors[0].title).to.be.equal("Missing relationship linkage.");
154+
});
155+
156+
it("should have the correct details", () => {
157+
expect(err.response.body.errors[0].details).to.be.equal("No data was found for the liaisons relationship.");
158+
});
159+
});
160+
});
153161
});
154162

155163
// "[S]erver implementations MUST ignore

0 commit comments

Comments
 (0)