Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb4de8b
commit 3bf79b6
Showing
8 changed files
with
184 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Resource from './Resource'; | ||
|
||
/** | ||
* Invites Resource. Will contain an {@link Array} containing all unused invites. | ||
*/ | ||
export default class InvitesResource extends Resource { | ||
/** | ||
* Get the invites {@link Array} | ||
* | ||
* @returns {Array<string>} Array containing unused invites | ||
*/ | ||
getInvites() { | ||
return this.getProperty('invites'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* eslint no-unused-expressions: "off" */ | ||
|
||
const chai = require('chai'); | ||
const fs = require('fs'); | ||
|
||
const Resource = require('../lib/resources/Resource').default; | ||
const InvitesResource = require('../lib/resources/InvitesResource').default; | ||
|
||
const should = chai.should(); | ||
|
||
describe('InvitesResource', () => { | ||
let resourceJson; | ||
let resource; | ||
before((done) => { | ||
fs.readFile(`${__dirname}/mocks/invites.json`, 'utf-8', (err, res) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
resourceJson = JSON.parse(res); | ||
return done(); | ||
}); | ||
}); | ||
beforeEach(() => { | ||
resource = new InvitesResource(resourceJson); | ||
}); | ||
afterEach(() => { | ||
resource = null; | ||
}); | ||
it('should be instance of Resource', () => { | ||
resource.should.be.instanceOf(Resource); | ||
}); | ||
it('should be instance of InvitesResource', () => { | ||
resource.should.be.instanceOf(InvitesResource); | ||
}); | ||
it('should instantiate with traversal and environment', () => { | ||
const res = new Resource(resourceJson, 'stage', {}); | ||
res.environment.should.be.equal('stage'); | ||
should.exist(res.traversal); | ||
}); | ||
it('should get invites', () => { | ||
const invites = resource.getInvites(); | ||
invites.should.be.instanceOf(Array); | ||
invites.forEach(invite => (typeof invite).should.be.equal('string')); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"invites": [ | ||
"375476f6-4732-4dfe-bd4c-0fe0dc57e19b", | ||
"26e1e48f-a11d-427f-8392-4aee6371e95e", | ||
"dcc4bafd-5fc4-47d1-b90b-2efe67be49f9", | ||
"6614ab11-14e1-40d8-8ed0-50693ef2113e", | ||
"7d04e725-e113-4e0d-8e33-2192a0f832f0", | ||
"4e8076c0-2e5a-423e-9a86-c4abdc283c21", | ||
"c3ec6ea9-8c84-43d7-9fa0-e0a1ee5d6214", | ||
"70b85711-d6ee-46b8-9a5b-8af2c7502df2", | ||
"ef5fa711-884a-40d2-9754-311b8b4bb309", | ||
"fbbdc462-7774-40f5-9d57-4148a395d472" | ||
], | ||
"_links": { | ||
"self": { | ||
"href": "https://accounts.entrecode.de/invite" | ||
}, | ||
"curies": { | ||
"href": "https://entrecode.de/doc/rel/{rel}", | ||
"templated": true | ||
}, | ||
"collection": { | ||
"href": "https://accounts.entrecode.de/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export declare class InvitesResource { | ||
constructor(resource: any, environment: string, traversal?: any); | ||
|
||
getInvites(): Array<string>; | ||
} |