Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
-布谷鸟-
nosqlclient
提交
a2f3acfe
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 搜索 >>
未验证
提交
a2f3acfe
编写于
4月 14, 2019
作者:
S
sercan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#480 connection tests
上级
eef18bad
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
134 addition
and
2 deletion
+134
-2
client/imports/test/ui/connection.tests.js
client/imports/test/ui/connection.tests.js
+134
-2
未找到文件。
client/imports/test/ui/connection.tests.js
浏览文件 @
a2f3acfe
...
...
@@ -4,11 +4,13 @@ import sinon from 'sinon';
import
{
expect
}
from
'
chai
'
;
import
{
FlowRouter
}
from
'
meteor/kadira:flow-router
'
;
import
{
Connection
}
from
'
/client/imports/ui
'
;
import
{
SessionManager
}
from
'
/client/imports/modules
'
;
import
{
Communicator
}
from
'
/client/imports/facades
'
;
import
{
ErrorHandler
,
SessionManager
,
Notification
}
from
'
/client/imports/modules
'
;
import
{
Communicator
,
ReactivityProvider
}
from
'
/client/imports/facades
'
;
import
$
from
'
jquery
'
;
import
Helper
from
'
/client/imports/helpers/helper
'
;
require
(
'
/client/plugins/colorpicker/js/bootstrap-colorpicker.min
'
);
describe
(
'
Connection
'
,
()
=>
{
describe
(
'
prepareModal tests
'
,
()
=>
{
const
translated
=
'
TESTTRANSLATED
'
;
...
...
@@ -97,4 +99,134 @@ describe('Connection', () => {
expect
(
FlowRouter
.
go
.
calledWithExactly
(
'
/databaseStats
'
)).
to
.
equals
(
true
);
});
});
describe
(
'
prepareContextMenu tests
'
,
()
=>
{
const
connectionId
=
'
12321312
'
;
const
connection
=
{
x
:
1
,
y
:
true
,
z
:
'
sercan
'
};
beforeEach
(()
=>
{
sinon
.
stub
(
$
,
'
contextMenu
'
);
sinon
.
stub
(
$
.
prototype
,
'
data
'
);
sinon
.
stub
(
$
.
prototype
,
'
modal
'
);
sinon
.
stub
(
$
.
prototype
,
'
DataTable
'
).
returns
({
row
:
sinon
.
stub
().
returns
({
data
:
sinon
.
stub
().
returns
({
_id
:
connectionId
})
})
});
sinon
.
stub
(
ReactivityProvider
,
'
findOne
'
).
returns
(
connection
);
sinon
.
stub
(
ErrorHandler
,
'
showMeteorFuncError
'
);
sinon
.
stub
(
Notification
,
'
success
'
);
sinon
.
stub
(
Connection
,
'
populateConnectionsTable
'
);
});
afterEach
(()
=>
{
$
.
contextMenu
.
restore
();
$
.
prototype
.
data
.
restore
();
$
.
prototype
.
modal
.
restore
();
$
.
prototype
.
DataTable
.
restore
();
ReactivityProvider
.
findOne
.
restore
();
ErrorHandler
.
showMeteorFuncError
.
restore
();
Notification
.
success
.
restore
();
Connection
.
populateConnectionsTable
.
restore
();
});
it
(
'
prepareContextMenu colorize callback
'
,
()
=>
{
// prepare
// execute
Connection
.
prepareContextMenu
();
$
.
contextMenu
.
getCall
(
0
).
args
[
0
].
items
.
colorize
.
callback
(
null
,
{
$trigger
:
[
'
something
'
]
});
// verify
expect
(
$
.
contextMenu
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
contextMenu
.
getCall
(
0
).
args
[
0
].
items
).
to
.
have
.
property
(
'
colorize
'
);
expect
(
$
.
contextMenu
.
getCall
(
0
).
args
[
0
].
items
).
to
.
have
.
property
(
'
clear_color
'
);
expect
(
$
.
prototype
.
data
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
prototype
.
data
.
calledWithExactly
(
'
connection
'
,
connectionId
)).
to
.
equal
(
true
);
expect
(
$
.
prototype
.
modal
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
prototype
.
modal
.
calledWithExactly
(
'
show
'
)).
to
.
equal
(
true
);
});
it
(
'
prepareContextMenu clear_color callback && communicator yields to error
'
,
()
=>
{
// prepare
const
error
=
{
error
:
'
123
'
};
sinon
.
stub
(
Communicator
,
'
call
'
).
yieldsTo
(
'
callback
'
,
error
,
null
);
// execute
Connection
.
prepareContextMenu
();
$
.
contextMenu
.
getCall
(
0
).
args
[
0
].
items
.
clear_color
.
callback
(
null
,
{
$trigger
:
[
'
something
'
]
});
// verify
expect
(
$
.
contextMenu
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
contextMenu
.
getCall
(
0
).
args
[
0
].
items
).
to
.
have
.
property
(
'
colorize
'
);
expect
(
$
.
contextMenu
.
getCall
(
0
).
args
[
0
].
items
).
to
.
have
.
property
(
'
clear_color
'
);
expect
(
Communicator
.
call
.
callCount
).
to
.
equal
(
1
);
expect
(
Communicator
.
call
.
calledWithMatch
({
methodName
:
'
saveConnection
'
,
args
:
{
connection
:
Object
.
assign
({
color
:
''
},
connection
)
},
callback
:
sinon
.
match
.
func
})).
to
.
equal
(
true
);
expect
(
ErrorHandler
.
showMeteorFuncError
.
callCount
).
to
.
equal
(
1
);
expect
(
ErrorHandler
.
showMeteorFuncError
.
calledWithExactly
(
error
,
null
)).
to
.
equal
(
true
);
// cleanup
Communicator
.
call
.
restore
();
});
it
(
'
prepareContextMenu clear_color callback && communicator yields to success
'
,
()
=>
{
// prepare
sinon
.
stub
(
Communicator
,
'
call
'
).
yieldsTo
(
'
callback
'
);
// execute
Connection
.
prepareContextMenu
();
$
.
contextMenu
.
getCall
(
0
).
args
[
0
].
items
.
clear_color
.
callback
(
null
,
{
$trigger
:
[
'
something
'
]
});
// verify
expect
(
$
.
contextMenu
.
callCount
).
to
.
equal
(
1
);
expect
(
$
.
contextMenu
.
getCall
(
0
).
args
[
0
].
items
).
to
.
have
.
property
(
'
colorize
'
);
expect
(
$
.
contextMenu
.
getCall
(
0
).
args
[
0
].
items
).
to
.
have
.
property
(
'
clear_color
'
);
expect
(
Communicator
.
call
.
callCount
).
to
.
equal
(
1
);
expect
(
Communicator
.
call
.
calledWithMatch
({
methodName
:
'
saveConnection
'
,
args
:
{
connection
:
Object
.
assign
({
color
:
''
},
connection
)
},
callback
:
sinon
.
match
.
func
})).
to
.
equal
(
true
);
expect
(
ErrorHandler
.
showMeteorFuncError
.
callCount
).
to
.
equal
(
0
);
expect
(
Notification
.
success
.
callCount
).
to
.
equal
(
1
);
expect
(
Notification
.
success
.
calledWithExactly
(
'
saved-successfully
'
)).
to
.
equal
(
true
);
expect
(
Connection
.
populateConnectionsTable
.
callCount
).
to
.
equal
(
1
);
expect
(
Connection
.
populateConnectionsTable
.
calledWithExactly
()).
to
.
equal
(
true
);
// cleanup
Communicator
.
call
.
restore
();
});
});
describe
(
'
prepareColorizeModal tests
'
,
()
=>
{
const
color
=
'
#111111
'
;
beforeEach
(()
=>
{
const
connectionId
=
'
1231235612
'
;
sinon
.
stub
(
$
.
prototype
,
'
colorpicker
'
);
sinon
.
stub
(
$
.
prototype
,
'
on
'
).
yields
(
null
);
sinon
.
stub
(
$
.
prototype
,
'
data
'
).
withArgs
(
'
connection
'
).
returns
(
connectionId
);
sinon
.
stub
(
ReactivityProvider
,
'
findOne
'
).
withArgs
(
ReactivityProvider
.
types
.
Connections
,
{
_id
:
connectionId
}).
returns
({
color
});
});
afterEach
(()
=>
{
$
.
prototype
.
colorpicker
.
restore
();
$
.
prototype
.
on
.
restore
();
$
.
prototype
.
data
.
restore
();
ReactivityProvider
.
findOne
.
restore
();
});
it
(
'
prepareColorizeModal
'
,
()
=>
{
// prepare
// execute
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
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录