Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "to start with" as an alias for "to begin with".
- Loading branch information
1 parent
4986d6a
commit dcbea8e
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*global expect*/ | ||
describe('to start with assertion', function() { | ||
it('should throw an error when the expected prefix is the empty string', function() { | ||
expect( | ||
function() { | ||
expect('foo', 'to start with', ''); | ||
}, | ||
'to throw', | ||
"The 'to start with' assertion does not support a prefix of the empty string" | ||
); | ||
}); | ||
|
||
describe('without the "not" flag', function() { | ||
it('asserts equality with a string', function() { | ||
expect('hello', 'to start with', 'hello'); | ||
expect('hello world', 'to start with', 'hello'); | ||
}); | ||
}); | ||
|
||
describe('when the assertion fails', function() { | ||
it('does not include a diff when there is no common prefix', function() { | ||
expect( | ||
function() { | ||
expect('hello world', 'to start with', 'foo'); | ||
}, | ||
'to throw exception', | ||
"expected 'hello world' to start with 'foo'" | ||
); | ||
}); | ||
|
||
it('includes a diff when there is a common prefix', function() { | ||
expect( | ||
function() { | ||
expect('hello world', 'to start with', 'hell yeah'); | ||
}, | ||
'to throw exception', | ||
"expected 'hello world' to start with 'hell yeah'\n" + | ||
'\n' + | ||
'hello world\n' + | ||
'^^^^' | ||
); | ||
}); | ||
}); | ||
}); |