Add first successful TypeScript test
parent
30a0ea216c
commit
80e34cf6d6
|
@ -2,7 +2,10 @@ module.exports = {
|
|||
projects: [
|
||||
{
|
||||
displayName: 'test',
|
||||
testPathIgnorePatterns: ['build', 'node_modules/(?!(jest-test))'],
|
||||
testPathIgnorePatterns: [
|
||||
'build',
|
||||
'<rootDir>/node_modules/(?!(jest-test))',
|
||||
],
|
||||
modulePaths: ['<rootDir>', '<rootDir>/node_modules/'],
|
||||
moduleDirectories: ['src'],
|
||||
setupFiles: ['<rootDir>/test/setupTests.js'],
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
"@types/enzyme": "^3.1.9",
|
||||
"@types/jest": "^22.1.4",
|
||||
"@types/lodash": "^4.14.104",
|
||||
"@types/mocha": "^2.2.48",
|
||||
"@types/node": "^9.4.6",
|
||||
"@types/prop-types": "^15.5.2",
|
||||
"@types/react": "^16.0.38",
|
||||
|
|
|
@ -16,7 +16,7 @@ export interface DatabaseListProps {
|
|||
query: Query
|
||||
querySource: Source
|
||||
onChooseNamespace: (namespace: Namespace) => void
|
||||
source: Source | null
|
||||
source: Source
|
||||
}
|
||||
|
||||
export interface DatabaseListState {
|
||||
|
@ -30,8 +30,8 @@ export interface DatabaseListContext {
|
|||
const {shape, string} = PropTypes
|
||||
|
||||
class DatabaseList extends Component<DatabaseListProps, DatabaseListState> {
|
||||
constructor() {
|
||||
super()
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.getDbRp = this.getDbRp.bind(this)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,22 +2,29 @@ export interface Source {
|
|||
id: string
|
||||
name: string
|
||||
url: string
|
||||
links: {
|
||||
proxy: string
|
||||
self: string
|
||||
kapacitors: string
|
||||
queries: string
|
||||
permissions: string
|
||||
users: string
|
||||
databases: string
|
||||
roles: string
|
||||
}
|
||||
type: string
|
||||
default: boolean
|
||||
telegraf?: string
|
||||
organization: string
|
||||
insecureSkipVerify: boolean
|
||||
role: string
|
||||
telegraf: string
|
||||
links: SourceLinks
|
||||
kapacitors?: Kapacitor[]
|
||||
metaUrl?: string
|
||||
}
|
||||
|
||||
export interface SourceLinks {
|
||||
self: string
|
||||
kapacitors: string
|
||||
proxy: string
|
||||
queries: string
|
||||
write: string
|
||||
permissions: string
|
||||
users: string
|
||||
databases: string
|
||||
roles?: string
|
||||
}
|
||||
|
||||
export interface Kapacitor {
|
||||
id?: string
|
||||
url: string
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
export const source = {
|
||||
id: '16',
|
||||
name: 'ssl',
|
||||
type: 'influx',
|
||||
username: 'admin',
|
||||
url: 'https://localhost:9086',
|
||||
insecureSkipVerify: true,
|
||||
default: false,
|
||||
telegraf: 'telegraf',
|
||||
organization: '0',
|
||||
role: 'viewer',
|
||||
links: {
|
||||
self: '/chronograf/v1/sources/16',
|
||||
kapacitors: '/chronograf/v1/sources/16/kapacitors',
|
||||
proxy: '/chronograf/v1/sources/16/proxy',
|
||||
queries: '/chronograf/v1/sources/16/queries',
|
||||
write: '/chronograf/v1/sources/16/write',
|
||||
permissions: '/chronograf/v1/sources/16/permissions',
|
||||
users: '/chronograf/v1/sources/16/users',
|
||||
databases: '/chronograf/v1/sources/16/dbs',
|
||||
},
|
||||
}
|
||||
|
||||
export const query = {
|
||||
id: '0',
|
||||
database: 'db1',
|
||||
measurement: 'm1',
|
||||
retentionPolicy: 'r1',
|
||||
fill: 'null',
|
||||
fields: [
|
||||
{
|
||||
value: 'f1',
|
||||
type: 'field',
|
||||
alias: 'foo',
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
tags: {
|
||||
tk1: ['tv1', 'tv2'],
|
||||
},
|
||||
groupBy: {
|
||||
time: null,
|
||||
tags: [],
|
||||
},
|
||||
areTagsAccepted: true,
|
||||
rawText: null,
|
||||
status: null,
|
||||
shifts: [],
|
||||
}
|
|
@ -2,31 +2,22 @@ import React from 'react'
|
|||
import DatabaseList from 'src/shared/components/DatabaseList'
|
||||
import {shallow} from 'enzyme'
|
||||
|
||||
const source = {
|
||||
links: {
|
||||
self: '/chronograf/v1/sources/16',
|
||||
kapacitors: '/chronograf/v1/sources/16/kapacitors',
|
||||
proxy: '/chronograf/v1/sources/16/proxy',
|
||||
queries: '/chronograf/v1/sources/16/queries',
|
||||
write: '/chronograf/v1/sources/16/write',
|
||||
permissions: '/chronograf/v1/sources/16/permissions',
|
||||
users: '/chronograf/v1/sources/16/users',
|
||||
databases: '/chronograf/v1/sources/16/dbs',
|
||||
},
|
||||
}
|
||||
import {query, source} from 'test/resources'
|
||||
|
||||
const setup = async (override = {}) => {
|
||||
const setup = (override = {}) => {
|
||||
const props = {
|
||||
query: {},
|
||||
source: {},
|
||||
querySource: {},
|
||||
query,
|
||||
source,
|
||||
querySource: source,
|
||||
onChooseNamespace: () => {},
|
||||
...override,
|
||||
}
|
||||
|
||||
DatabaseList.prototype.getDbRp = jest.fn(() => Promise.resolve())
|
||||
|
||||
const dbList = await shallow(<DatabaseList {...props} />, {context: {source})
|
||||
const dbList = shallow(<DatabaseList {...props} />, {
|
||||
context: {source},
|
||||
})
|
||||
|
||||
return {
|
||||
dbList,
|
||||
|
|
|
@ -49,10 +49,6 @@
|
|||
version "4.14.104"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.104.tgz#53ee2357fa2e6e68379341d92eb2ecea4b11bb80"
|
||||
|
||||
"@types/mocha@^2.2.48":
|
||||
version "2.2.48"
|
||||
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.48.tgz#3523b126a0b049482e1c3c11877460f76622ffab"
|
||||
|
||||
"@types/node@*", "@types/node@^9.4.6":
|
||||
version "9.4.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.6.tgz#d8176d864ee48753d053783e4e463aec86b8d82e"
|
||||
|
|
Loading…
Reference in New Issue