|
1 | 1 | import chai from "chai"; |
2 | | -import {RequestClient} from "../../../src/http"; |
| 2 | +import { RequestClient } from "../../../src/http"; |
3 | 3 | import sinon from "sinon"; |
4 | 4 | import CompanyFilingHistoryService from "../../../src/services/company-filing-history/service"; |
5 | 5 | import { |
6 | | - CompanyFilingHistoryResource, |
7 | | - FilingHistoryItemResource |
| 6 | + CompanyFilingHistoryResource, |
| 7 | + FilingHistoryItemResource |
8 | 8 | } from "../../../src/services/company-filing-history/types"; |
9 | 9 |
|
10 | 10 | const expect = chai.expect; |
11 | 11 |
|
12 | 12 | const requestClient = new RequestClient({ baseUrl: "URL-NOT-USED", oauthToken: "TOKEN-NOT-USED" }); |
13 | 13 |
|
14 | 14 | describe("company-filing-history", () => { |
15 | | - beforeEach(() => { |
16 | | - sinon.reset(); |
17 | | - sinon.restore(); |
18 | | - }); |
| 15 | + beforeEach(() => { |
| 16 | + sinon.reset(); |
| 17 | + sinon.restore(); |
| 18 | + }); |
19 | 19 |
|
20 | | - afterEach(done => { |
21 | | - sinon.reset(); |
22 | | - sinon.restore(); |
23 | | - done(); |
24 | | - }); |
| 20 | + afterEach(done => { |
| 21 | + sinon.reset(); |
| 22 | + sinon.restore(); |
| 23 | + done(); |
| 24 | + }); |
25 | 25 |
|
26 | | - it("returns an error response on failure", async () => { |
27 | | - const mockGetResponse = { |
28 | | - status: 401, |
29 | | - error: "An error occurred" |
30 | | - }; |
31 | | - const mockRequest = sinon.stub(requestClient, "httpGet").resolves(mockGetResponse); |
32 | | - const companyFilingService : CompanyFilingHistoryService = new CompanyFilingHistoryService(requestClient); |
33 | | - const data = await companyFilingService.getCompanyFilingHistory("NUMBER-NOT-IMPORTANT"); |
| 26 | + it("returns an error response on failure", async () => { |
| 27 | + const mockGetResponse = { |
| 28 | + status: 401, |
| 29 | + error: "An error occurred" |
| 30 | + }; |
| 31 | + const mockRequest = sinon.stub(requestClient, "httpGet").resolves(mockGetResponse); |
| 32 | + const companyFilingService : CompanyFilingHistoryService = new CompanyFilingHistoryService(requestClient); |
| 33 | + const data = await companyFilingService.getCompanyFilingHistory("NUMBER-NOT-IMPORTANT"); |
34 | 34 |
|
35 | | - expect(data.httpStatusCode).to.equal(401); |
36 | | - expect(data.resource).to.be.undefined; |
37 | | - }); |
| 35 | + expect(data.httpStatusCode).to.equal(401); |
| 36 | + expect(data.resource).to.be.undefined; |
| 37 | + }); |
38 | 38 |
|
39 | | - it("maps the company filing history data items correctly", async () => { |
40 | | - const mockFilingHistoryItem: FilingHistoryItemResource = { |
41 | | - category: "category", |
42 | | - date: "someDate", |
43 | | - description: "A description", |
44 | | - transaction_id: "transaction id", |
45 | | - type: "a type" |
46 | | - } |
47 | | - const mockResponseBody : CompanyFilingHistoryResource = { |
48 | | - etag: "someEtag", |
49 | | - filing_history_status: "someFilingHistoryStatus", |
50 | | - items: [mockFilingHistoryItem], |
51 | | - items_per_page: 1, |
52 | | - kind: "a kind", |
53 | | - start_index: 0, |
54 | | - total_count: 1 |
55 | | - }; |
| 39 | + it("maps the company filing history data items correctly", async () => { |
| 40 | + const mockFilingHistoryItem: FilingHistoryItemResource = { |
| 41 | + category: "category", |
| 42 | + date: "someDate", |
| 43 | + description: "A description", |
| 44 | + transaction_id: "transaction id", |
| 45 | + type: "a type" |
| 46 | + } |
| 47 | + const mockResponseBody : CompanyFilingHistoryResource = { |
| 48 | + etag: "someEtag", |
| 49 | + filing_history_status: "someFilingHistoryStatus", |
| 50 | + items: [mockFilingHistoryItem], |
| 51 | + items_per_page: 1, |
| 52 | + kind: "a kind", |
| 53 | + start_index: 0, |
| 54 | + total_count: 1 |
| 55 | + }; |
56 | 56 |
|
57 | | - const mockGetResponse = { |
58 | | - status: 200, |
59 | | - body: mockResponseBody |
60 | | - }; |
| 57 | + const mockGetResponse = { |
| 58 | + status: 200, |
| 59 | + body: mockResponseBody |
| 60 | + }; |
61 | 61 |
|
62 | | - const mockRequest = sinon.stub(requestClient, "httpGet").resolves(mockGetResponse); |
63 | | - const companyFilingHistoryService : CompanyFilingHistoryService = new CompanyFilingHistoryService(requestClient); |
64 | | - const data = await companyFilingHistoryService.getCompanyFilingHistory("123"); |
| 62 | + const mockRequest = sinon.stub(requestClient, "httpGet").resolves(mockGetResponse); |
| 63 | + const companyFilingHistoryService : CompanyFilingHistoryService = new CompanyFilingHistoryService(requestClient); |
| 64 | + const data = await companyFilingHistoryService.getCompanyFilingHistory("123"); |
65 | 65 |
|
66 | | - expect(data.httpStatusCode).to.equal(200); |
| 66 | + expect(data.httpStatusCode).to.equal(200); |
67 | 67 |
|
68 | | - expect(data.resource.etag).to.equal(mockResponseBody.etag) |
69 | | - expect(data.resource.filingHistoryStatus).to.equal(mockResponseBody.filing_history_status) |
70 | | - expect(data.resource.itemsPerPage).to.equal(mockResponseBody.items_per_page) |
71 | | - expect(data.resource.kind).to.equal(mockResponseBody.kind) |
72 | | - expect(data.resource.startIndex).to.equal(mockResponseBody.start_index) |
73 | | - expect(data.resource.totalCount).to.equal(mockResponseBody.total_count) |
| 68 | + expect(data.resource.etag).to.equal(mockResponseBody.etag) |
| 69 | + expect(data.resource.filingHistoryStatus).to.equal(mockResponseBody.filing_history_status) |
| 70 | + expect(data.resource.itemsPerPage).to.equal(mockResponseBody.items_per_page) |
| 71 | + expect(data.resource.kind).to.equal(mockResponseBody.kind) |
| 72 | + expect(data.resource.startIndex).to.equal(mockResponseBody.start_index) |
| 73 | + expect(data.resource.totalCount).to.equal(mockResponseBody.total_count) |
74 | 74 |
|
75 | | - expect(data.resource.items[0].category).to.equal(mockFilingHistoryItem.category); |
76 | | - expect(data.resource.items[0].date).to.equal(mockFilingHistoryItem.date); |
77 | | - expect(data.resource.items[0].description).to.equal(mockFilingHistoryItem.description); |
78 | | - expect(data.resource.items[0].transactionId).to.equal(mockFilingHistoryItem.transaction_id); |
79 | | - expect(data.resource.items[0].type).to.equal(mockFilingHistoryItem.type); |
| 75 | + expect(data.resource.items[0].category).to.equal(mockFilingHistoryItem.category); |
| 76 | + expect(data.resource.items[0].date).to.equal(mockFilingHistoryItem.date); |
| 77 | + expect(data.resource.items[0].description).to.equal(mockFilingHistoryItem.description); |
| 78 | + expect(data.resource.items[0].transactionId).to.equal(mockFilingHistoryItem.transaction_id); |
| 79 | + expect(data.resource.items[0].type).to.equal(mockFilingHistoryItem.type); |
80 | 80 | }); |
81 | 81 | }); |
0 commit comments