|
| 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