Improve suite names. Use toMatch matcher
This commit is contained in:
parent
85e419afc5
commit
624ab458d0
@ -10,13 +10,13 @@
|
|||||||
return (new Array(times + 1)).join(this+' ').replace(/\s$/, '');
|
return (new Array(times + 1)).join(this+' ').replace(/\s$/, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
return describe("xmppchat.ClientStorage", function() {
|
return describe("Local storage of messages and open chats", function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
this.storage = new xmppchat.ClientStorage('dummy@localhost');
|
this.storage = new xmppchat.ClientStorage('dummy@localhost');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("storing open chats", function () {
|
describe("open chat storage", function () {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
// Removes all stored items
|
// Removes all stored items
|
||||||
@ -66,7 +66,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("storing messages", function () {
|
describe("message storage", function () {
|
||||||
|
|
||||||
var iso_regex = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/;
|
var iso_regex = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/;
|
||||||
|
|
||||||
@ -87,8 +87,7 @@
|
|||||||
// First two space separated strings are ISO date and direction
|
// First two space separated strings are ISO date and direction
|
||||||
var msg_arr = msgs[i].split(' ', 2);
|
var msg_arr = msgs[i].split(' ', 2);
|
||||||
// Check that first string is ISO format
|
// Check that first string is ISO format
|
||||||
var match = msg_arr[0].match(iso_regex);
|
expect(msg_arr[0]).toMatch(iso_regex);
|
||||||
expect(match).toBeTruthy();
|
|
||||||
expect(msg_arr[0]).toEqual(jasmine.any(String));
|
expect(msg_arr[0]).toEqual(jasmine.any(String));
|
||||||
expect(msg_arr[1]).toEqual('to');
|
expect(msg_arr[1]).toEqual('to');
|
||||||
expect(msgs[i].replace(/(.*?\s.*?\s)/, '')).toEqual(msg);
|
expect(msgs[i].replace(/(.*?\s.*?\s)/, '')).toEqual(msg);
|
||||||
@ -97,10 +96,9 @@
|
|||||||
|
|
||||||
it("should be able to get last message", function () {
|
it("should be able to get last message", function () {
|
||||||
var msg = this.storage.getLastMessage('chat@localhost'),
|
var msg = this.storage.getLastMessage('chat@localhost'),
|
||||||
msg_arr = msg.split(' ', 2),
|
msg_arr = msg.split(' ', 2);
|
||||||
match = msg_arr[0].match(iso_regex);
|
|
||||||
|
|
||||||
expect(match).toBeTruthy();
|
expect(msg_arr[0]).toMatch(iso_regex);
|
||||||
expect(msg_arr[0]).toEqual(jasmine.any(String));
|
expect(msg_arr[0]).toEqual(jasmine.any(String));
|
||||||
expect(msg_arr[1]).toEqual('to');
|
expect(msg_arr[1]).toEqual('to');
|
||||||
expect(msg.replace(/(.*?\s.*?\s)/, '')).toEqual('msg'.repeat(10));
|
expect(msg.replace(/(.*?\s.*?\s)/, '')).toEqual('msg'.repeat(10));
|
||||||
|
Loading…
Reference in New Issue
Block a user