Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 755b916

Browse files
committed
EventSpec
1 parent be6846e commit 755b916

File tree

2 files changed

+154
-0
lines changed

2 files changed

+154
-0
lines changed

GithubSwift.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@
288288
D2F488571CCC26B2005DD009 /* branch.json in Resources */ = {isa = PBXBuildFile; fileRef = D2F488551CCC26B2005DD009 /* branch.json */; };
289289
D2F488591CCC29CF005DD009 /* ContentSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2F488581CCC29CF005DD009 /* ContentSpec.swift */; };
290290
D2F4885A1CCC29CF005DD009 /* ContentSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2F488581CCC29CF005DD009 /* ContentSpec.swift */; };
291+
D2F4885C1CCC2E07005DD009 /* EventSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2F4885B1CCC2E07005DD009 /* EventSpec.swift */; };
292+
D2F4885D1CCC2E07005DD009 /* EventSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2F4885B1CCC2E07005DD009 /* EventSpec.swift */; };
291293
D5B2E8AA1C3A780C00C0327D /* GithubSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5B2E89F1C3A780C00C0327D /* GithubSwift.framework */; };
292294
D5C6294A1C3A7FAA007F7B7C /* GithubSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5C629401C3A7FAA007F7B7C /* GithubSwift.framework */; };
293295
D5C629771C3A878E007F7B7C /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5C629751C3A878E007F7B7C /* Quick.framework */; };
@@ -452,6 +454,7 @@
452454
D2F488521CCC261B005DD009 /* TreeSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TreeSpec.swift; sourceTree = "<group>"; };
453455
D2F488551CCC26B2005DD009 /* branch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = branch.json; sourceTree = "<group>"; };
454456
D2F488581CCC29CF005DD009 /* ContentSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentSpec.swift; sourceTree = "<group>"; };
457+
D2F4885B1CCC2E07005DD009 /* EventSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventSpec.swift; sourceTree = "<group>"; };
455458
D500FD111C3AABED00782D78 /* Playground-iOS.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = "Playground-iOS.playground"; sourceTree = "<group>"; };
456459
D500FD121C3AAC8E00782D78 /* Playground-Mac.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = "Playground-Mac.playground"; sourceTree = "<group>"; };
457460
D5B2E89F1C3A780C00C0327D /* GithubSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GithubSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -687,6 +690,7 @@
687690
D2F4884F1CCC2615005DD009 /* BranchSpec.swift */,
688691
D2F488521CCC261B005DD009 /* TreeSpec.swift */,
689692
D2F488581CCC29CF005DD009 /* ContentSpec.swift */,
693+
D2F4885B1CCC2E07005DD009 /* EventSpec.swift */,
690694
);
691695
path = Classes;
692696
sourceTree = "<group>";
@@ -1337,6 +1341,7 @@
13371341
D2F488501CCC2615005DD009 /* BranchSpec.swift in Sources */,
13381342
D2F473EF1CBC221D00057D9C /* OrganizationSpec.swift in Sources */,
13391343
D2F473F41CBC294E00057D9C /* RespositorySpec.swift in Sources */,
1344+
D2F4885C1CCC2E07005DD009 /* EventSpec.swift in Sources */,
13401345
D2F473EC1CBC1E5B00057D9C /* ResponseSpec.swift in Sources */,
13411346
D2BABA371CC6D1DD00245C3D /* UserSpec.swift in Sources */,
13421347
);
@@ -1459,6 +1464,7 @@
14591464
D2F488511CCC2615005DD009 /* BranchSpec.swift in Sources */,
14601465
D2F473F01CBC221D00057D9C /* OrganizationSpec.swift in Sources */,
14611466
D2F473F51CBC294F00057D9C /* RespositorySpec.swift in Sources */,
1467+
D2F4885D1CCC2E07005DD009 /* EventSpec.swift in Sources */,
14621468
D2F473ED1CBC1E5B00057D9C /* ResponseSpec.swift in Sources */,
14631469
D2BABA381CC6D1DD00245C3D /* UserSpec.swift in Sources */,
14641470
);
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
//
2+
// EventSpec.swift
3+
// GithubSwift
4+
//
5+
// Created by Khoa Pham on 24/04/16.
6+
// Copyright © 2016 Fantageek. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import GithubSwift
11+
import Quick
12+
import Nimble
13+
import Mockingjay
14+
import RxSwift
15+
import Sugar
16+
17+
class EventSpec: QuickSpec {
18+
override func spec() {
19+
20+
describe("event") {
21+
var events: [String: GithubSwift.Event] = [:]
22+
23+
beforeEach {
24+
(Helper.readJSON("events") as JSONArray).map({ Event($0) }).forEach {
25+
events[$0!.objectID] = $0
26+
}
27+
}
28+
29+
it("OCTCommitCommentEvent should have deserialized") {
30+
let event = events["1605861091"] as! CommitCommentEvent
31+
32+
expect(event.repositoryName).to(equal("github/twui"))
33+
expect(event.actorLogin).to(equal("galaxas0"))
34+
expect(event.organizationLogin).to(equal("github"))
35+
expect(event.date).to(equal(Formatter.date(string: "2012-10-02 22:03:12 +0000")))
36+
}
37+
38+
it("OCTPullRequestCommentEvent should have deserialized") {
39+
let event = events["1605868324"] as! PullRequestCommentEvent
40+
41+
expect(event.repositoryName).to(equal("github/ReactiveCocoa"))
42+
expect(event.actorLogin).to(equal("jspahrsummers"))
43+
expect(event.organizationLogin).to(equal("github"))
44+
45+
expect(event.comment!.reviewComment!.position).to(equal(14))
46+
expect(event.comment!.originalPosition).to(equal(14))
47+
expect(event.comment!.reviewComment!.commitSHA).to(equal("7e731834f7fa981166cbb509a353dbe02eb5d1ea"))
48+
expect(event.comment!.originalCommitSHA).to(equal("7e731834f7fa981166cbb509a353dbe02eb5d1ea"))
49+
expect(event.pullRequest).to(beNil())
50+
}
51+
52+
it("OCTIssueCommentEvent should have deserialized") {
53+
let event = events["1605861266"] as! IssueCommentEvent
54+
55+
expect(event.repositoryName).to(equal("github/twui"))
56+
expect(event.actorLogin).to(equal("galaxas0"))
57+
expect(event.organizationLogin).to(equal("github"))
58+
}
59+
60+
it("OCTPushEvent should have deserialized") {
61+
let event = events["1605847260"] as! PushEvent
62+
63+
expect(event.repositoryName).to(equal("github/ReactiveCocoa"))
64+
expect(event.actorLogin).to(equal("joshaber"))
65+
expect(event.organizationLogin).to(equal("github"))
66+
67+
expect((event.commitCount)).to(equal(36))
68+
expect((event.distinctCommitCount)).to(equal(5))
69+
expect(event.previousHeadSHA).to(equal("623934b71f128f9bcc44482d6dc76b7fd4848d4d"))
70+
expect(event.currentHeadSHA).to(equal("da01b97c85d2a2d2b8e4021c2e3dff693a8f2c6b"))
71+
expect(event.branchName).to(equal("new-demo"))
72+
}
73+
74+
it("OCTPullRequestEvent should have deserialized") {
75+
let event = events["1605849683"] as! PullRequestEvent
76+
77+
expect(event.repositoryName).to(equal("github/ReactiveCocoa"))
78+
expect(event.actorLogin).to(equal("joshaber"))
79+
expect(event.organizationLogin).to(equal("github"))
80+
81+
expect((event.action)).to(equal(IssueAction.Opened))
82+
}
83+
84+
it("OCTPullRequestEventAssignee should have deserialized") {
85+
let event = events["1605825804"] as! PullRequestEvent
86+
87+
expect(event.pullRequest!.assignee!.objectID).to(equal("432536"))
88+
expect(event.pullRequest!.assignee!.login).to(equal("jspahrsummers"))
89+
}
90+
91+
it("OCTIssueEvent should have deserialized") {
92+
let event = events["1605857918"] as! IssueEvent
93+
94+
expect(event.repositoryName).to(equal("github/twui"))
95+
expect(event.actorLogin).to(equal("jwilling"))
96+
expect(event.organizationLogin).to(equal("github"))
97+
98+
expect((event.action)).to(equal(IssueAction.Opened))
99+
100+
}
101+
102+
it("OCTRefEvent should have deserialized") {
103+
let event = events["1605847125"] as! RefEvent
104+
105+
expect(event.repositoryName).to(equal("github/ReactiveCocoa"))
106+
expect(event.actorLogin).to(equal("joshaber"))
107+
expect(event.organizationLogin).to(equal("github"))
108+
109+
expect((event.refType)).to(equal((RefType.Branch)))
110+
expect((event.eventType)).to(equal(RefEventType.Created))
111+
expect(event.refName).to(equal("perform-selector"))
112+
}
113+
114+
it("OCTForkEvent should have deserialized") {
115+
let event = events["2483893273"] as! ForkEvent
116+
117+
expect(event.repositoryName).to(equal("thoughtbot/Argo"))
118+
expect(event.actorLogin).to(equal("jspahrsummers"))
119+
120+
expect(event.forkedRepositoryName).to(equal("jspahrsummers/Argo"))
121+
}
122+
123+
it("OCTMemberEvent should have deserialized") {
124+
let event = events["2472813496"] as! MemberEvent
125+
126+
expect(event.repositoryName).to(equal("niftyn8/degenerate"))
127+
expect(event.actorLogin).to(equal("niftyn8"))
128+
129+
expect(event.memberLogin).to(equal("houndci"))
130+
expect((event.action)).to(equal((MemberAction.Added)))
131+
}
132+
133+
it("OCTPublicEvent should have deserialized") {
134+
let event = events["2485152382"] as! PublicEvent
135+
136+
expect(event.repositoryName).to(equal("ethanjdiamond/AmIIn"))
137+
expect(event.actorLogin).to(equal("ethanjdiamond"))
138+
}
139+
140+
it("OCTWatchEvent should have deserialized") {
141+
let event = events["2484426974"] as! WatchEvent
142+
143+
expect(event.repositoryName).to(equal("squiidz/bone"))
144+
expect(event.actorLogin).to(equal("mattmassicotte"))
145+
}
146+
}
147+
}
148+
}

0 commit comments

Comments
 (0)