-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
129 additions
and
9 deletions.
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
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
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,39 @@ | ||
var assert = require('assert'); | ||
|
||
describe('stuff', function() { | ||
var stuff = require('../stuff'); | ||
|
||
describe('extendQuery', function() { | ||
var extendQuery = stuff.extendQuery; | ||
|
||
it('новые параметры добавляются', function() { | ||
var newUrl = 'https://www.search.ru/?q=beer'; | ||
var oldUrl = 'https://www.search.ru/'; | ||
|
||
assert.equal(extendQuery(oldUrl, newUrl), 'https://www.search.ru/?q=beer'); | ||
}); | ||
|
||
it('если параметров нет в новом УРЛе, то они остаются от старого', function() { | ||
var newUrl = 'https://www.search.ru/?q=beer'; | ||
var oldUrl = 'https://www.search.ru/?r=whiskey'; | ||
|
||
assert.equal(extendQuery(oldUrl, newUrl), 'https://www.search.ru/?r=whiskey&q=beer'); | ||
}); | ||
|
||
it('если параметр есть и там, и там, берется новое значение', function() { | ||
var newUrl = 'https://www.search.ru/?q=beer'; | ||
var oldUrl = 'https://www.search.ru/?q=whiskey'; | ||
|
||
assert.equal(extendQuery(oldUrl, newUrl), 'https://www.search.ru/?q=beer'); | ||
}); | ||
|
||
it('прочие части нового УРЛа остаются неизменными', function() { | ||
var newUrl = 'https://www.search.ru/?q=beer'; | ||
var oldUrl = 'http://another.ru/search/?q=beer'; | ||
|
||
assert.equal(extendQuery(oldUrl, newUrl), 'https://www.search.ru/?q=beer'); | ||
}); | ||
|
||
}); | ||
|
||
}); |