Reorganised tests to make way for more tests!

This commit is contained in:
Andrew Naylor 2015-03-05 08:13:25 +00:00
Родитель 6e64ce86ed
Коммит 230e175bcb
1 изменённых файлов: 43 добавлений и 40 удалений

Просмотреть файл

@ -86,7 +86,7 @@ describe("Notification", function() {
});
describe("trim", function() {
describe("notification payload is below the maximum length", function() {
describe("when notification payload is below the maximum length", function() {
it("returns zero",function() {
note.alert = "test message";
expect(note.trim()).to.equal(0);
@ -101,50 +101,53 @@ describe("Notification", function() {
});
});
var longText = 'ㅂㅈ ㅐ: LONDON (AP) — E\\\veryone says there areare lots of hidden costs to owning a home. If you own a palace, the costs are royal.\n\nThat became evident when the Buckingham Palace released its accounts Thursday, which showed the monarchy cost British taxpayers 35.7 million pounds ($60.8 million) last year — 56 pence (just under $1) for everyone in the country.\n\nThat is 7.2 percent, or 2.4 million pounds, more than the year before and the increase is mainly explained by the British royal family\'s repair bills.\n\nTheir properties are hardly typical. Buckingham Palace, for example, has 240 bedrooms and 78 bathrooms. That\'s a lot of plumbing to fix when things go wrong.\n\nSo it\'s no surprise that more than a third of the money British taxpayers paid for the monarchy, led by Queen Elizabeth II, was spent on repairs, improvements and maintenance of aging but still opulent palaces.\n\n"We continue to focus on value for money," said Keeper of the Privy Purse Alan Reid, asserting that careful spending habits had allowed for more money to be used for important maintenance work.\n\n\nFILE - In this Saturday, June 14, 2014 file photo, Britain\'s Queen Elizabeth II, foreground, sur …\nA big part of the fixer-upper budget in the 12 months that ended on March 31 went to creating a suitable home for the young family of Prince William, his wife Kate and their toddler Prince George.\n\nSome 3.4 million pounds of taxpayer funds were used to refurbish part of London\'s Kensington Palace for the couple. The extensive work included removing asbestos, installing new heating and redecorating.\n\nThe couple, who have considerable personal financial resources in part because of the estate left by Princess Diana, paid for the carpets, curtains and furniture out of personal funds, the palace said.\n\nIn addition, Prince Charles\' private secretary, William Nye, suggested that Charles and his wife Camilla — who are supported by profits from the extensive Duchy of Cornwall estate — may have helped William and Kate set up their new home.\n\nThe palace accounts also showed the high cost of entertaining on a royal scale: 2 million pounds were spent on "housekeeping and hospitality" in the 12 months that ended on March 31.\n---ending ---\n\n';
describe("with default length", function() {
it("trims notification text to reduce payload to maximum length", function () {
note.alert = longText
note.trim();
expect(note.length()).to.equal(2048);
});
it("trims notification alert body to reduce payload to maximum length", function () {
note.alert = {
body: longText
};
note.trim();
expect(note.length()).to.equal(2048);
});
});
describe("with specified length", function() {
it("trims correctly", function() {
note.alert = "12345";
var trimLength = note.length() - 2;
note.trim(trimLength);
expect(note.length()).to.equal(trimLength);
describe("when notification payload is greater than the maximum", function() {
var longText = 'ㅂㅈ ㅐ: LONDON (AP) — E\\\veryone says there areare lots of hidden costs to owning a home. If you own a palace, the costs are royal.\n\nThat became evident when the Buckingham Palace released its accounts Thursday, which showed the monarchy cost British taxpayers 35.7 million pounds ($60.8 million) last year — 56 pence (just under $1) for everyone in the country.\n\nThat is 7.2 percent, or 2.4 million pounds, more than the year before and the increase is mainly explained by the British royal family\'s repair bills.\n\nTheir properties are hardly typical. Buckingham Palace, for example, has 240 bedrooms and 78 bathrooms. That\'s a lot of plumbing to fix when things go wrong.\n\nSo it\'s no surprise that more than a third of the money British taxpayers paid for the monarchy, led by Queen Elizabeth II, was spent on repairs, improvements and maintenance of aging but still opulent palaces.\n\n"We continue to focus on value for money," said Keeper of the Privy Purse Alan Reid, asserting that careful spending habits had allowed for more money to be used for important maintenance work.\n\n\nFILE - In this Saturday, June 14, 2014 file photo, Britain\'s Queen Elizabeth II, foreground, sur …\nA big part of the fixer-upper budget in the 12 months that ended on March 31 went to creating a suitable home for the young family of Prince William, his wife Kate and their toddler Prince George.\n\nSome 3.4 million pounds of taxpayer funds were used to refurbish part of London\'s Kensington Palace for the couple. The extensive work included removing asbestos, installing new heating and redecorating.\n\nThe couple, who have considerable personal financial resources in part because of the estate left by Princess Diana, paid for the carpets, curtains and furniture out of personal funds, the palace said.\n\nIn addition, Prince Charles\' private secretary, William Nye, suggested that Charles and his wife Camilla — who are supported by profits from the extensive Duchy of Cornwall estate — may have helped William and Kate set up their new home.\n\nThe palace accounts also showed the high cost of entertaining on a royal scale: 2 million pounds were spent on "housekeeping and hospitality" in the 12 months that ended on March 31.\n---ending ---\n\n';
describe("with default length", function() {
it("trims notification text to reduce payload to maximum length", function () {
note.alert = longText
note.trim();
expect(note.length()).to.equal(2048);
});
it("trims notification alert body to reduce payload to maximum length", function () {
note.alert = {
body: longText
};
note.trim();
expect(note.length()).to.equal(2048);
});
});
it("trims to length longer than default", function() {
note.alert = longText + longText;
var trimLength = 4096;
note.trim(trimLength);
expect(note.length()).to.equal(4096);
});
});
describe("with custom length", function() {
it("trims to a shorter length than default", function() {
note.alert = "12345";
var trimLength = note.length() - 2;
note.trim(trimLength);
expect(note.length()).to.equal(trimLength);
});
describe("alert with escape sequences", function() {
it("strips correctly", function () {
note.alert = "\n\n\n";
var trimLength = note.length() - 2;
note.trim(trimLength);
expect(note.length()).to.equal(trimLength);
it("trims to a longer length than default", function() {
note.alert = longText + longText;
var trimLength = 4096;
note.trim(trimLength);
expect(note.length()).to.equal(4096);
});
});
it("strips trailing escape characters", function () {
note.alert = "test\\ message";
expect(note.trim(26)).to.equal(8);
describe("alert contains escape sequences at trim point", function() {
it("strips them", function () {
note.alert = "\n\n\n";
var trimLength = note.length() - 2;
note.trim(trimLength);
expect(note.alert).to.equal("\n\n");
});
it("strips orphaned escape character", function () {
note.alert = "test\\ message";
note.trim(26);
expect(note.alert).to.equal("test");
});
});
});