Skip to content
This repository has been archived by the owner on Jul 20, 2019. It is now read-only.

Commit

Permalink
Implemented labels (#6).
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswilddev committed May 27, 2019
1 parent 7bd96bf commit 35aad94
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.tests.ts
Expand Up @@ -10,6 +10,7 @@ import * as floatColumn from "./float-column"
import * as column from "./column"
import * as columnSet from "./column-set"
import * as labelPart from "./label-part"
import * as label from "./label"
import * as schema from "./schema"
import * as index from "./index"

Expand Down Expand Up @@ -48,6 +49,9 @@ describe(`index`, () => {
describe(`label part`, () => {
it(`schema`, () => expect(index.labelPart).toBe(labelPart.schema))
})
describe(`label`, () => {
it(`schema`, () => expect(index.label).toBe(label.schema))
})
describe(`schema`, () => {
it(`schema`, () => expect(index.schema).toBe(schema.schema))
})
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Expand Up @@ -53,6 +53,11 @@ export {
Type as LabelPart
} from "./label-part"

export {
schema as label,
Type as Label
} from "./label"

export {
schema as schema,
Type as Schema
Expand Down
17 changes: 17 additions & 0 deletions src/label.tests.ts
@@ -0,0 +1,17 @@
import "jasmine"
import * as label from "./label"
import * as shared from "./shared.tests"

describe(`label`, () => {
shared.run(shared.nonArrays, value => shared.rejects(
label.schema, value, `instance`, `is not of a type(s) array`
))
shared.run(shared.emptyArrays, value => shared.accepts(label.schema, value))
shared.testLabelPart(label.schema, instance => [instance], `instance[0]`)
describe(`example`, () => shared.accepts(label.schema, [
[`for_eg`, `la_run`, `mu_par`],
[],
[`just_1`],
[`long_w`, `2thetp`, `wanna_`, `depest`, `lore__`]
]))
})
14 changes: 14 additions & 0 deletions src/label.ts
@@ -0,0 +1,14 @@
import * as jsonschema from "jsonschema"
import * as labelPart from "./label-part"

export const schema: jsonschema.Schema = {
description: `A list of chains of column identifiers which can be followed to find values which are concatenated to build a label.`,
type: `array`,
items: labelPart.schema
}

/**
* A list of chains of column identifiers which can be followed to find values
* which are concatenated to build a label.
*/
export type Type = ReadonlyArray<labelPart.Type>

0 comments on commit 35aad94

Please sign in to comment.