-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds strongly typed support for 'options' & 'taxonomy_group' type ele…
…ments (#16)
- Loading branch information
Showing
9 changed files
with
167 additions
and
8 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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
export interface IContentTypeElement{ | ||
import { IContentTypeOption } from './icontent-type-option.interface'; | ||
|
||
export interface IContentTypeElement { | ||
codename: string; | ||
type: string; | ||
name: string; | ||
taxonomyGroup?: string; | ||
options?: IContentTypeOption[]; | ||
} |
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,4 @@ | ||
export interface IContentTypeOption{ | ||
name: string; | ||
codename: 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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import { IContentTypeElement } from '../../interfaces/type/icontent-type-element.interface'; | ||
import { IContentTypeOption } from '../../interfaces/type/icontent-type-option.interface'; | ||
|
||
export class ContentTypeElement implements IContentTypeElement { | ||
export class ContentTypeElement implements IContentTypeElement{ | ||
constructor( | ||
public codename: string, | ||
public type: string, | ||
public name: string | ||
){} | ||
public name: string, | ||
public taxonomyGroup?: string, | ||
public options?: IContentTypeOption[] | ||
) { } | ||
} |
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,8 @@ | ||
import { IContentTypeOption } from '../../interfaces/type/icontent-type-option.interface'; | ||
|
||
export class ContentTypeOption implements IContentTypeOption{ | ||
constructor( | ||
public name: string, | ||
public codename: 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,64 @@ | ||
// setup | ||
import { setup, Context, Actor, Movie } from '../../setup'; | ||
|
||
// models | ||
import { ItemResponses, FieldModels, TypeResponses } from '../../../lib'; | ||
|
||
// tests | ||
describe('Live type', () => { | ||
|
||
var context = new Context(); | ||
setup(context); | ||
|
||
var codename: string = 'movie'; | ||
var response: TypeResponses.DeliveryTypeResponse; | ||
|
||
var multipleChoiceElement: string = 'category'; | ||
var taxonomyElement: string = 'releasecategory'; | ||
|
||
beforeAll((done) => { | ||
context.deliveryClient.type(codename) | ||
.get() | ||
.subscribe(r => { | ||
response = r as TypeResponses.DeliveryTypeResponse; | ||
done(); | ||
}); | ||
}); | ||
|
||
it(`type should be defined`, () => { | ||
console.log(response); | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it(`elements should be defined`, () => { | ||
expect(response.type.elements).toBeDefined(); | ||
}); | ||
|
||
it(`system properties should be defined`, () => { | ||
expect(response.type.system).toBeDefined(); | ||
}); | ||
|
||
it(`proper type should be returned based on test config`, () => { | ||
expect(response.type.system.codename).toEqual(codename); | ||
}); | ||
|
||
it(`Verifies taxonomy element - '${taxonomyElement}'`, () => { | ||
var releaseCategoryElement = response.type.elements.find(m => m.codename === taxonomyElement); | ||
|
||
expect(releaseCategoryElement).toBeDefined(); | ||
expect(releaseCategoryElement.taxonomyGroup).toBeDefined(); | ||
expect(releaseCategoryElement.taxonomyGroup).toEqual('releasecategory'); | ||
}); | ||
|
||
it(`Verifies multiple_choice element - '${multipleChoiceElement}'`, () => { | ||
var categoryElement = response.type.elements.find(m => m.codename === multipleChoiceElement); | ||
|
||
expect(categoryElement).toBeDefined(); | ||
expect(categoryElement.options).toBeDefined(); | ||
expect(categoryElement.options.length).toBeGreaterThan(0); | ||
expect(categoryElement.options[0].codename).toBeDefined(); | ||
expect(categoryElement.options[0].name).toBeDefined(); | ||
}); | ||
|
||
}); | ||
|
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,44 @@ | ||
// setup | ||
import { setup, Context, Actor, Movie } from '../../setup'; | ||
|
||
// models | ||
import { ItemResponses, FieldModels, TypeResponses } from '../../../lib'; | ||
|
||
// tests | ||
describe('Live types', () => { | ||
|
||
var context = new Context(); | ||
setup(context); | ||
|
||
var response: TypeResponses.DeliveryTypeListingResponse; | ||
|
||
beforeAll((done) => { | ||
context.deliveryClient.types() | ||
.get() | ||
.subscribe(r => { | ||
response = r as TypeResponses.DeliveryTypeListingResponse; | ||
done(); | ||
}); | ||
}); | ||
|
||
it(`types should be defined`, () => { | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it(`there should be at least 1 type`, () => { | ||
expect(response.types.length).toBeGreaterThan(0); | ||
}); | ||
|
||
it(`elements should be defined`, () => { | ||
expect(response.types[0].elements).toBeDefined(); | ||
}); | ||
|
||
it(`system properties should be defined`, () => { | ||
expect(response.types[0].system).toBeDefined(); | ||
}); | ||
|
||
it(`pagination should be defined`, () => { | ||
expect(response.pagination).toBeDefined(); | ||
}); | ||
}); | ||
|