Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
-布谷鸟-
nosqlclient
提交
65e777f7
N
nosqlclient
项目概览
-布谷鸟-
/
nosqlclient
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nosqlclient
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
65e777f7
编写于
4月 15, 2019
作者:
R
rsercano
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#480 connection tests
上级
a2f3acfe
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
150 addition
and
16 deletion
+150
-16
.eslintrc
.eslintrc
+1
-1
client/imports/test/ui/connection.tests.js
client/imports/test/ui/connection.tests.js
+145
-11
client/imports/ui/connection/index.js
client/imports/ui/connection/index.js
+4
-4
未找到文件。
.eslintrc
浏览文件 @
65e777f7
...
...
@@ -25,7 +25,7 @@ rules:
func-style: [2, 'expression']
parserOptions:
ecmaVersion:
6
ecmaVersion:
9
sourceType: module
env:
...
...
client/imports/test/ui/connection.tests.js
浏览文件 @
65e777f7
...
...
@@ -91,12 +91,12 @@ describe('Connection', () => {
Connection
.
disconnect
();
// verify
expect
(
Communicator
.
call
.
callCount
).
to
.
equal
s
(
1
);
expect
(
Communicator
.
call
.
calledWithMatch
({
methodName
:
'
disconnect
'
})).
to
.
equal
s
(
true
);
expect
(
SessionManager
.
clear
.
callCount
).
to
.
equal
s
(
1
);
expect
(
SessionManager
.
clear
.
calledWithExactly
()).
to
.
equal
s
(
true
);
expect
(
FlowRouter
.
go
.
callCount
).
to
.
equal
s
(
1
);
expect
(
FlowRouter
.
go
.
calledWithExactly
(
'
/databaseStats
'
)).
to
.
equal
s
(
true
);
expect
(
Communicator
.
call
.
callCount
).
to
.
equal
(
1
);
expect
(
Communicator
.
call
.
calledWithMatch
({
methodName
:
'
disconnect
'
})).
to
.
equal
(
true
);
expect
(
SessionManager
.
clear
.
callCount
).
to
.
equal
(
1
);
expect
(
SessionManager
.
clear
.
calledWithExactly
()).
to
.
equal
(
true
);
expect
(
FlowRouter
.
go
.
callCount
).
to
.
equal
(
1
);
expect
(
FlowRouter
.
go
.
calledWithExactly
(
'
/databaseStats
'
)).
to
.
equal
(
true
);
});
});
...
...
@@ -222,11 +222,145 @@ describe('Connection', () => {
Connection
.
prepareColorizeModal
();
// verify
expect
(
$
.
prototype
.
colorpicker
.
callCount
).
to
.
equals
(
2
);
expect
(
$
.
prototype
.
colorpicker
.
calledWithMatch
({
align
:
'
left
'
,
format
:
'
hex
'
})).
to
.
equals
(
true
);
expect
(
$
.
prototype
.
colorpicker
.
calledWithMatch
(
'
setValue
'
,
color
)).
to
.
equals
(
true
);
expect
(
$
.
prototype
.
on
.
callCount
).
to
.
equals
(
1
);
expect
(
$
.
prototype
.
on
.
calledWithMatch
(
'
shown.bs.modal
'
,
sinon
.
match
.
func
)).
to
.
equals
(
true
);
expect
(
$
.
prototype
.
colorpicker
.
callCount
).
to
.
equal
(
2
);
expect
(
$
.
prototype
.
colorpicker
.
calledWithMatch
({
align
:
'
left
'
,
format
:
'
hex
'
})).
to
.
equal
(
true
);
expect
(
$
.
prototype
.
colorpicker
.
calledWithMatch
(
'
setValue
'
,
color
)).
to
.
equal
(
true
);
expect
(
$
.
prototype
.
on
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
prototype
.
on
.
calledWithMatch
(
'
shown.bs.modal
'
,
sinon
.
match
.
func
)).
to
.
equal
(
true
);
});
});
describe
(
'
colorize tests
'
,
()
=>
{
const
connectionId
=
'
1231235612
'
;
const
color
=
'
#111111
'
;
const
connection
=
{
x
:
1
,
y
:
true
,
color
:
'
test
'
};
beforeEach
(()
=>
{
sinon
.
stub
(
ReactivityProvider
,
'
findOne
'
).
withArgs
(
ReactivityProvider
.
types
.
Connections
,
{
_id
:
connectionId
}).
returns
(
connection
);
sinon
.
stub
(
Notification
,
'
error
'
);
sinon
.
stub
(
Notification
,
'
success
'
);
sinon
.
stub
(
ErrorHandler
,
'
showMeteorFuncError
'
);
sinon
.
stub
(
Connection
,
'
populateConnectionsTable
'
);
});
afterEach
(()
=>
{
$
.
prototype
.
val
.
restore
();
$
.
prototype
.
data
.
restore
();
ReactivityProvider
.
findOne
.
restore
();
Communicator
.
call
.
restore
();
Notification
.
error
.
restore
();
ErrorHandler
.
showMeteorFuncError
.
restore
();
Notification
.
success
.
restore
();
Connection
.
populateConnectionsTable
.
restore
();
});
it
(
'
colorize no color
'
,
()
=>
{
// prepare
sinon
.
stub
(
$
.
prototype
,
'
val
'
);
sinon
.
stub
(
$
.
prototype
,
'
data
'
);
sinon
.
stub
(
Communicator
,
'
call
'
);
// execute
Connection
.
colorize
();
// verify
expect
(
$
.
prototype
.
data
.
callCount
).
to
.
equal
(
0
);
expect
(
Communicator
.
call
.
callCount
).
to
.
equal
(
0
);
expect
(
ReactivityProvider
.
findOne
.
callCount
).
to
.
equal
(
0
);
expect
(
Notification
.
error
.
callCount
).
to
.
equal
(
1
);
expect
(
Notification
.
error
.
calledWithExactly
(
'
color-required
'
)).
to
.
equal
(
true
);
expect
(
Connection
.
populateConnectionsTable
.
callCount
).
to
.
equal
(
0
);
});
it
(
'
colorize no connectionId
'
,
()
=>
{
// prepare
sinon
.
stub
(
$
.
prototype
,
'
val
'
).
returns
(
color
);
sinon
.
stub
(
$
.
prototype
,
'
data
'
);
sinon
.
stub
(
Communicator
,
'
call
'
);
// execute
Connection
.
colorize
();
// verify
expect
(
$
.
prototype
.
val
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
prototype
.
val
.
calledWithExactly
()).
to
.
equal
(
true
);
expect
(
$
.
prototype
.
val
.
getCall
(
0
).
thisValue
.
selector
).
to
.
equal
(
'
#inputColor
'
);
expect
(
$
.
prototype
.
data
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
prototype
.
data
.
calledWithExactly
(
'
connection
'
)).
to
.
equal
(
true
);
expect
(
$
.
prototype
.
data
.
getCall
(
0
).
thisValue
.
selector
).
to
.
equal
(
'
#colorizeModal
'
);
expect
(
Communicator
.
call
.
callCount
).
to
.
equal
(
0
);
expect
(
ReactivityProvider
.
findOne
.
callCount
).
to
.
equal
(
0
);
expect
(
Notification
.
error
.
callCount
).
to
.
equal
(
1
);
expect
(
Notification
.
error
.
calledWithExactly
(
'
select-connection
'
)).
to
.
equal
(
true
);
expect
(
Connection
.
populateConnectionsTable
.
callCount
).
to
.
equal
(
0
);
});
it
(
'
colorize communicator yields to erorr
'
,
()
=>
{
// prepare
const
error
=
{
error
:
'
1233
'
};
sinon
.
stub
(
$
.
prototype
,
'
val
'
).
returns
(
color
);
sinon
.
stub
(
$
.
prototype
,
'
data
'
).
returns
(
connectionId
);
sinon
.
stub
(
Communicator
,
'
call
'
).
yieldsTo
(
'
callback
'
,
error
,
null
);
// execute
Connection
.
colorize
();
// verify
const
newConnection
=
{
...
connection
};
newConnection
.
color
=
color
;
expect
(
$
.
prototype
.
val
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
prototype
.
val
.
calledWithExactly
()).
to
.
equal
(
true
);
expect
(
$
.
prototype
.
val
.
getCall
(
0
).
thisValue
.
selector
).
to
.
equal
(
'
#inputColor
'
);
expect
(
$
.
prototype
.
data
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
prototype
.
data
.
calledWithExactly
(
'
connection
'
)).
to
.
equal
(
true
);
expect
(
$
.
prototype
.
data
.
getCall
(
0
).
thisValue
.
selector
).
to
.
equal
(
'
#colorizeModal
'
);
expect
(
Notification
.
error
.
callCount
).
to
.
equal
(
0
);
expect
(
ReactivityProvider
.
findOne
.
callCount
).
to
.
equal
(
1
);
expect
(
ReactivityProvider
.
findOne
.
calledWithExactly
(
ReactivityProvider
.
types
.
Connections
,
{
_id
:
connectionId
})).
to
.
equal
(
true
);
expect
(
Communicator
.
call
.
callCount
).
to
.
equal
(
1
);
expect
(
Communicator
.
call
.
calledWithMatch
({
methodName
:
'
saveConnection
'
,
args
:
{
connection
:
newConnection
},
callback
:
sinon
.
match
.
func
})).
to
.
equal
(
true
);
expect
(
ErrorHandler
.
showMeteorFuncError
.
callCount
).
to
.
equal
(
1
);
expect
(
ErrorHandler
.
showMeteorFuncError
.
calledWithExactly
(
error
,
null
)).
to
.
equal
(
true
);
expect
(
Connection
.
populateConnectionsTable
.
callCount
).
to
.
equal
(
0
);
});
it
(
'
colorize communicator yields to success
'
,
()
=>
{
// prepare
sinon
.
stub
(
$
.
prototype
,
'
val
'
).
returns
(
color
);
sinon
.
stub
(
$
.
prototype
,
'
data
'
).
returns
(
connectionId
);
sinon
.
stub
(
Communicator
,
'
call
'
).
yieldsTo
(
'
callback
'
,
null
,
{});
// execute
Connection
.
colorize
();
// verify
const
newConnection
=
{
...
connection
};
newConnection
.
color
=
color
;
expect
(
$
.
prototype
.
val
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
prototype
.
val
.
calledWithExactly
()).
to
.
equal
(
true
);
expect
(
$
.
prototype
.
val
.
getCall
(
0
).
thisValue
.
selector
).
to
.
equal
(
'
#inputColor
'
);
expect
(
$
.
prototype
.
data
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
prototype
.
data
.
calledWithExactly
(
'
connection
'
)).
to
.
equal
(
true
);
expect
(
$
.
prototype
.
data
.
getCall
(
0
).
thisValue
.
selector
).
to
.
equal
(
'
#colorizeModal
'
);
expect
(
Notification
.
error
.
callCount
).
to
.
equal
(
0
);
expect
(
ReactivityProvider
.
findOne
.
callCount
).
to
.
equal
(
1
);
expect
(
ReactivityProvider
.
findOne
.
calledWithExactly
(
ReactivityProvider
.
types
.
Connections
,
{
_id
:
connectionId
})).
to
.
equal
(
true
);
expect
(
Communicator
.
call
.
callCount
).
to
.
equal
(
1
);
expect
(
Communicator
.
call
.
calledWithMatch
({
methodName
:
'
saveConnection
'
,
args
:
{
connection
:
newConnection
},
callback
:
sinon
.
match
.
func
})).
to
.
equal
(
true
);
expect
(
ErrorHandler
.
showMeteorFuncError
.
callCount
).
to
.
equal
(
0
);
expect
(
Connection
.
populateConnectionsTable
.
callCount
).
to
.
equal
(
1
);
expect
(
Connection
.
populateConnectionsTable
.
calledWithExactly
()).
to
.
equal
(
true
);
expect
(
Notification
.
success
.
callCount
).
to
.
equal
(
1
);
expect
(
Notification
.
success
.
calledWithExactly
(
'
saved-successfully
'
)).
to
.
equal
(
true
);
});
});
});
client/imports/ui/connection/index.js
浏览文件 @
65e777f7
...
...
@@ -89,20 +89,20 @@ Connection.prototype = {
},
colorize
()
{
const
color
=
$
(
'
#inputColor
'
);
const
connectionId
=
$
(
'
#colorizeModal
'
).
data
(
'
connection
'
);
if
(
!
color
.
val
())
{
const
color
=
$
(
'
#inputColor
'
).
val
();
if
(
!
color
)
{
Notification
.
error
(
'
color-required
'
);
return
;
}
const
connectionId
=
$
(
'
#colorizeModal
'
).
data
(
'
connection
'
);
if
(
!
connectionId
)
{
Notification
.
error
(
'
select-connection
'
);
return
;
}
const
connection
=
ReactivityProvider
.
findOne
(
ReactivityProvider
.
types
.
Connections
,
{
_id
:
connectionId
});
connection
.
color
=
color
.
val
()
;
connection
.
color
=
color
;
Communicator
.
call
({
methodName
:
'
saveConnection
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录