Instant download JavaScript Unit Testing 1st Edition Hazem Saleh pdf all chapter
Instant download JavaScript Unit Testing 1st Edition Hazem Saleh pdf all chapter
com
https://ebookname.com/product/javascript-unit-testing-1st-
edition-hazem-saleh/
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebookname.com/product/pro-jsf-and-html5-building-rich-
internet-components-2nd-edition-hazem-saleh/
ebookname.com
https://ebookname.com/product/pragmatic-unit-testing-in-java-with-
junit-1st-edition-andy-hunt/
ebookname.com
https://ebookname.com/product/modern-economic-thought-sidney-
weintraub-editor/
ebookname.com
Teach Yourself VISUALLY Dreamweaver CS4 1st Edition Janine
C. Warner
https://ebookname.com/product/teach-yourself-visually-dreamweaver-
cs4-1st-edition-janine-c-warner/
ebookname.com
https://ebookname.com/product/duchess-of-palms-a-memoir-1st-edition-
nadine-eckhardt/
ebookname.com
https://ebookname.com/product/this-bright-light-of-ours-stories-from-
the-voting-rights-fight-1st-edition-maria-gitin/
ebookname.com
Hazem Saleh
BIRMINGHAM - MUMBAI
www.it-ebooks.info
JavaScript Unit Testing
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78216-062-5
www.packtpub.com
www.it-ebooks.info
Credits
Reviewer Proofreaders
Allan Lykke Christensen Lawrence A. Herman
Joel Johnson
Acquisition Editor
Jonathan Titmus Indexer
Hemangini Bari
Commissioning Editors
Harsha Bharwani Graphics
Priyanka Shah Aditi Gajjar
www.it-ebooks.info
About the Author
Hazem Saleh has 9 years of experience in JEE and open source technologies.
He has worked as a technical consultant for different clients in Europe (Sweden),
North America (USA, Canada), South America (Peru), Africa (Egypt), and Asia
(Qatar, Kuwait). He is an Apache MyFaces committer, and the founder of many
open source projects.
Besides being the co-author of the book The Definitive Guide to Apache MyFaces
and Facelets, Zubin Wadia, Martin Marinschek, Hazem Saleh, Dennis Byrne, Apress
and the author of this book, Hazem is also an author of many technical articles,
a developerWorks contributing author, and a technical speaker at both local and
international conferences, such as the IBM Regional Technical Exchange, CONFESS,
and JavaOne. Hazem is now working for IBM Egypt (Cairo Lab SWG Services) as
an Advisory Software Engineer. He is a Web 2.0 subject matter expert and an IBM
Certified Expert IT Specialist.
www.it-ebooks.info
About the Reviewer
www.it-ebooks.info
www.PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub
files available? You can upgrade to the eBook version at www.PacktPub.com and as a print
book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via web browser
www.it-ebooks.info
Table of Contents
Preface 1
Chapter 1: Unit Testing JavaScript Applications 7
What unit testing is 7
Why we need unit testing 8
What Test-Driven Development (TDD) is 10
Complexities in testing JavaScript applications 11
Weather forecasting application 13
Exploring the application's HTML and JavaScript code 15
Running the weather application 28
Summary 29
Chapter 2: Jasmine 31
Configuration 31
Writing your first Jasmine test 32
The nested describe blocks 38
Jasmine matchers 39
The toBe matcher 39
The toBeDefined and toBeUndefined matchers 40
The toBeNull matcher 41
The toBeTruthy and toBeFalsy matchers 41
The toContain matcher 42
The toBeLessThan and toBeGreaterThan matchers 42
The toMatch matcher 43
Developing custom Jasmine matchers 43
Testing asynchronous (Ajax) JavaScript code 45
The runs() function 45
The waits() function 46
The waitsFor() function 47
The spyOn() function 49
www.it-ebooks.info
Table of Contents
HTML fixtures 51
Configuring the jasmine-jquery plugin 52
The loadFixtures module 53
Testing the weather application 55
Testing the LoginClient object 56
Testing the RegistrationClient object 59
Testing the WeatherClient object 63
Running the weather application tests 63
Summary 63
Chapter 3: YUI Test 65
Writing your first YUI test 67
Assertions 74
The assert assertion 74
The areEqual and areNotEqual assertions 75
The areSame and areNotSame assertions 75
The datatype assertions 75
Special value assertions 76
The fail assertion 77
Testing asynchronous (Ajax) JavaScript code 78
The wait and resume functions 78
Testing the weather application 79
Testing the LoginClient object 80
Testing the RegistrationClient object 84
Testing the WeatherClient object 88
Running the weather application tests 89
Generating test reports 89
Automation and integration with build management tools 95
Configuring YUI Test Selenium Driver 95
Using YUI Test Selenium Driver in the weather application 96
Integration with build management tools 98
Summary 99
Chapter 4: QUnit 101
Configuration 101
Writing your first QUnit test 102
Assertions 108
The ok assertion 108
The equal and notEqual assertions 109
The deepEqual and notDeepEqual assertions 109
The expect assertion 110
Developing custom QUnit assertions 111
[ ii ]
www.it-ebooks.info
Table of Contents
[ iii ]
www.it-ebooks.info
www.it-ebooks.info
Preface
One of the biggest challenges of many web applications is being supported
by different browsers with different versions. JavaScript code that runs on
the Safari browser will not necessarily run correctly on Internet Explorer (IE),
Firefox, or Google chrome browsers. This challenge is caused by the lack of unit
testing of the JavaScript code that has lived in the web application from day one.
Without unit testing the JavaScript code, more money will have to be spent for
testing and retesting the application's web pages after deciding to upgrade to
current, supported browsers (or after updating the JavaScript code of the web
pages with non-trivial features).
The JavaScript Unit Testing book is a comprehensive practical guide that illustrates
in detail how to efficiently create and automate JavaScript tests for web applications
using popular, JavaScript unit testing frameworks, such as Jasmine, YUI Test, QUnit,
and JsTestDriver.
This book explains the concept of JavaScript unit testing and explores the bits of an
interactive Ajax web application (the weather application). Throughout the book,
the JavaScript part of the weather application is tested using different JavaScript unit
testing frameworks. The book illustrates how to generate test and code coverage
reports of developed JavaScript tests. It also explains how to automate the running of
JavaScript tests from build and continuous integration tools. The book shows how to
integrate different JavaScript unit testing frameworks with each other in order to test
web applications in the most efficient way.
www.it-ebooks.info
Preface
Chapter 2, Jasmine, helps you learn what Jasmine is and how to use it for testing
synchronous JavaScript code. You will learn how to test asynchronous (Ajax)
JavaScript code using the Jasmine Spies, waitsFor, and runs mechanisms. You will
learn how to perform mock Ajax testing using Jasmine. You will learn about the
various matchers provided by the framework, and how to load HTML fixtures in
your Jasmine tests. In this chapter, you will learn how to use Jasmine for testing the
weather application's JavaScript section.
Chapter 3, YUI Test, helps you to learn what YUI Test is and how to use this
JavaScript unit testing framework for testing synchronous JavaScript code. You will
learn how to test asynchronous (Ajax) JavaScript code using the YUI Test's wait and
resume mechanisms. You will learn about the various assertions provided by the
framework, how to display XML and JSON test reports using framework reporter
APIs, and how to generate test reports automatically using the YUI Test Selenium
Driver. You will learn how to automate running YUI tests using the YUI Test
Selenium Driver, and how to integrate an automation script with build management
and continuous integration tools. In this chapter, you will learn how to use YUI Test
for testing the weather application's JavaScript section.
Chapter 4, QUnit, helps you to understand what QUnit is and how to use it for
testing synchronous JavaScript code. You will learn how to test asynchronous
(Ajax) JavaScript code using the QUnit test mechanism and the QUnit asyncTest
mechanism. You will also learn the different assertions provided by the framework,
and how to develop your own assertion in order to simplify your test code. You will
learn how to load HTML fixtures in your QUnit tests. In this chapter, you will learn
how to use the framework for testing the weather application's JavaScript section.
Chapter 5, JsTestDriver, helps you to learn what JsTestDriver (JSTD) is, the JSTD
architecture, the JSTD configuration, and how to use JSTD for testing synchronous
JavaScript code. You will learn how to test asynchronous (Ajax) JavaScript code
using the JSTD AsyncTestCase object. You will learn the various assertions provided
by the framework, and how to generate test and code coverage reports using the
framework's code coverage plugin. You will learn how to use JSTD as a test runner
for the other JavaScript unit testing frameworks mentioned in the book, such as
[2]
www.it-ebooks.info
Preface
Jasmine and QUnit, in order to enable the execution of the tests of these frameworks
from the command-line interface. You will learn how to integrate the tests of
JSTD (and the tests of the JavaScript frameworks on top of JSTD) with build and
continuous integration tools. You will learn how to work with the JSTD framework
in one of the most popular integrated development environments (IDEs) which
is Eclipse. In this chapter, you will learn how to use JSTD for testing the weather
application's JavaScript section.
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
[3]
www.it-ebooks.info
Preface
var loginForm = {
"userNameField" : "username",
"passwordField" : "password",
"userNameMessage" : "usernameMessage",
"passwordMessage" : "passwordMessage"
};
return loginClient.validateLoginForm(loginForm);
}
New terms and important words are shown in bold. Words that you see on the
screen, in menus or dialog boxes, for example, appear in the text like this: "In this
application, the user enters his/her name and then clicks on the Welcome button."
[4]
www.it-ebooks.info
Preface
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for
us to develop titles that you really get the most out of.
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things
to help you to get the most from your purchase.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you would report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/support, selecting your book, clicking on the errata submission form link, and
entering the details of your errata. Once your errata are verified, your submission
will be accepted and the errata will be uploaded on our website, or added to any list
of existing errata, under the Errata section of that title. Any existing errata can be
viewed by selecting your title from http://www.packtpub.com/support.
[5]
www.it-ebooks.info
Preface
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media.
At Packt, we take the protection of our copyright and licenses very seriously. If you
come across any illegal copies of our works, in any form, on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
We appreciate your help in protecting our authors, and our ability to bring you
valuable content.
Questions
You can contact us at questions@packtpub.com if you are having a problem with
any aspect of the book, and we will do our best to address it.
[6]
www.it-ebooks.info
Unit Testing JavaScript
Applications
Before going into the details of unit testing JavaScript applications, we need to
understand first what unit testing is and why we need to unit test our applications.
This chapter also shows the complexities of testing JavaScript applications and
why it is not as simple as desktop applications. Finally, the chapter illustrates the
functionality and the JavaScript code of a sample weather application. We will unit
test its JavaScript code in the following chapters of the book.
The definition is technically correct; however, it does not show us how to make
a really good unit test. In order to write a good unit test, we need to understand
the requirements of a good unit test.
www.it-ebooks.info
Unit Testing JavaScript Applications
As shown in the following figure, a good unit test should be automated, repeatable,
easy to understand, incremental, easy to run, and fast.
A good unit test should be automated and repeatable, which means that other
team members can repeat running the application unit tests for every significant
code change automatically. It should also be easy to understand so that other team
members can understand what your test means and can continue adding more test
cases or updating an existing test case. A good unit test should be incremental; this
means that the unit test should be updated if a new relevant defect is detected in the
code, which means that this defect will not happen again as long as this unit test is
running periodically. Finally, a good unit test should be easy to run; it should run
by executing a command or by clicking a button and should not take a long time
for execution because fast unit tests can help in increasing the development
team's productivity.
So let's go back to the definition and refine it. Unit testing is a piece of code
(usually a method) that invokes another piece of code and checks the correctness
of some assumptions later. Unit testing should be automated, repeatable, easy to
understand, incremental, easy to run, and fast.
[8]
www.it-ebooks.info
Chapter 1
Without unit testing, the integration of the different components in the system
becomes complicated. This complexity results from the tracing of the defects of not
only the integration between the components but also each "buggy" component. This
complicates the life of the developers by making them spend nights in the office in
order to meet the schedule.
The number of new defects and the regression defects becomes unmanageable when
the code base becomes complicated and unit testing is not available. The developer
can resolve a specific defect and, after a set of code changes, this defect can happen
again because there is no repeatable test case to ensure that the defect will not
happen again.
Having more number of defects per lines of code affects the application's quality
badly, and this means that more time has to be spent on testing the application.
Bad quality applications have a longer test cycle for each project deployment
(or phase), because they have a high probability of having more defects for every
code change, which leads to more pressure on the project management, the project
developers, and the project testers.
Having good unit testing can be a good reference for the system documentation
because it contains the test scenarios of the system use cases. In addition to this,
unit testing shows how the system APIs are used, which reflect the current design
of the system. This means that unit testing is a powerful basis of code and design
refactoring for having more enhancements in the system.
Having good unit testing minimizes the number of regression defects because in good
unit testing the system has a repeatable number of test cases for every relevant defect.
Having a continuous integration job that runs periodically on the application unit tests
will ensure that these defects will not happen again, because if a specific defect appears
again due to a change in the application code, then the developer will be notified to fix
the defect and ensure that the test case of this defect passes successfully.
As a result of reducing the regression defects, having good unit testing reduces the
test cycle for each phase (or system deployment). In addition to this, the application
can have more and more features per iterations or phases peacefully without
worrying if these features shall break an existing module that has good unit tests.
[9]
www.it-ebooks.info
Unit Testing JavaScript Applications
As shown in the following figure, traditional unit testing is about writing the
application code first. It can simply be a class or a method. After writing the piece
of code, the unit tests, which test the functionality of the code, are written. Then the
unit tests run. If the unit tests fail then the developer fixes the defects and runs the
unit tests again. If the unit tests succeed then the developer can either refactor the
code and run the tests again or continue to write the next piece of code and so on.
As shown in the following figure, TDD starts by writing a failing unit test to indicate
that the functionality is missing. After writing the unit test, the unit test must be run
to ensure that it fails. After that, the developer writes the application code that meets
the unit test expectation. The unit test must be run again to ensure that it succeeds.
If it fails then the developer fixes the bugs and if it succeeds the developer can either
refactor the application code or continue writing the next test case.
[ 10 ]
www.it-ebooks.info
Chapter 1
TDD is a powerful technique, as it can give you more control on the application code
and design; however, it is a double-edged sword because if it is done incorrectly,
writing the tests can waste a lot of time and the schedule of the project can slip.
Finally, either you are using TDD or traditional unit testing technique. Don't forget
to make your tests automated, repeatable, easy to understand, incremental, easy to
run, and fast.
Testing existing JavaScript web applications (with many web pages) on new
browsers that are not supported by the application code is not a flexible process.
Supporting a new unsupported browser means allocating more time for testing the
application again on this new browser and for the new/regression defects to be fixed
by the developers. Let's see a simple Broken JavaScript example, which illustrates
this idea. In this example, the user enters his/her name and then clicks on the
Welcome button. After that the welcome message appears.
[ 11 ]
www.it-ebooks.info
Unit Testing JavaScript Applications
</body>
</html>
If you run the code shown in the previous code snippet, you will find that it works
fine in Internet Explorer (IE) and Safari while it does not work in Firefox (to be more
specific, this example works on Internet Explorer 8 and Safari 5.1, while it will not
work on Firefox 3.6). The reason behind this problem is that the innerText property
is not supported in Firefox. This is one of the hundreds of examples that show a code
that works in a specific browser while it does not work in another one.
[ 12 ]
www.it-ebooks.info
Chapter 1
The weather forecasting application is a Java web application. The server-side part of
the application is written using Java servlets (http://docs.oracle.com/javaee/6/
tutorial/doc/bnafd.html). If you are not familiar with Java servlets, do not
worry. This book focuses only on JavaScript unit testing; all you need to know about
these servlets is the functionality of each one of them, not the code behind it. The
functionality of each application servlet will be explained during when the JavaScript
code is explained, to show you the complete Ajax request life cycle with the server.
Another thing that needs to be mentioned is that the weather application pages
are .jsp files; however, 99 percent of their code is pure HTML code that is easy to
understand (the application pages code will be explained in detail in the next section).
The first screen of the application is the login screen in which the user enters his
username and password, as shown in the following screenshot:
[ 13 ]
www.it-ebooks.info
Unit Testing JavaScript Applications
When the user clicks on the Login button, there is a JavaScript login client that
ensures that the username and the password are entered correctly. If the username
and the password are correct, they are submitted to the server, which validates them
if the user is registered in the application. If the user is registered in the application
then the user is redirected to the weather checking page; otherwise an error message
appears to the user.
The username field must not be empty and has to be in a valid e-mail address format.
The password field also must not be empty and has to contain at least one digit, one
capital, one small character, and at least one special character. The password length
has to be six characters or more.
In the weather checking page, the user can select one of the available cities from the
combobox, then click on the Get weather condition button to get the current weather
information of the selected city, as shown in the following screenshot:
In the user registration page, the user can register in the application by entering
his username and confirmed password, as shown in the following screenshot:
[ 14 ]
www.it-ebooks.info
Random documents with unrelated
content Scribd suggests to you:
in the great heat, from which they sought to shelter their heads
under their neighbours’ bellies, the horses stood, each one with his
plumed and impure rider. “Sometimes,” says the Doctor, “I saw
ravens sitting in the same confidential manner upon the backs of
horses and dromedaries. In North Africa I observed similar intimacy
between kites and cows, ravens and swine. Dr Knoblecher relates
that in the Nile districts of Central Africa he often saw waterfowl,
particularly herons and ibises, sit upon the backs of elephants. Only
to one kind of animal has the Armenian caravan-horse a natural
hatred and strong aversion—namely, to the camel, who, on his side,
detests the horse. Even in caravans composed of both kinds of
beasts, long accustomed to each other’s presence, this antipathy
endures. Horses and camels, if left in any degree to their own free
will, go separately to pasture. Long habit of being together restrains
them from hostile outbreaks, but I never witnessed, during the whole
period of my Oriental travels, an example of even a tolerably good
understanding between them.”
On the 20th of June—so cold a morning, that, in spite of cloak and
mackintosh, Dr Wagner was half-frozen—the caravan reached the
Kourd village of Yendek, and encamped in a narrow valley, the
mountains around which had been reckoned, a few years previously,
amongst the most unsafe in Kourdistan, a caravan seldom passing
unassailed. Towards evening a Kourd chief came into camp. “He
wore no beard, but thick and long moustaches—as formerly the
Janissaries—a huge turban, a short burka, very wide trousers. He
had his horse shod by one of our Armenians, took a fancy to Karapet-
Bedochil’s pocket-knife, and asked him for it as a keepsake. He did
not pay for the shoeing, and rode off, with small thanks, amidst the
courteous greetings of all the Armenians—even of our haughty
Karivan-Baschi. I afterwards laughingly asked the Kadertshi why he
had not demanded payment from the Kourd for the shoes and his
work. ‘Laugh away!’ was his reply; ‘if ever you meet that fellow alone,
you won’t be quite so merry.’ The Kourd, who was armed with
pistols, gun, and sabre, certainly looked the very model of a captain
of banditti.”
Before reaching Persian territory, where the risk from robbers
diminishes, some pack-horses were cleverly stolen by the Kourds;
and two men, who were sent, well mounted, to overtake the thieves
and negotiate for the restoration of the property, returned to camp
despoiled of clothes and steeds. Ultimately, the Pasha of Erzroum
extorted the bales from the Kourds, who are too prudent to drive
things to extremities. But, for the time, Kara Gos had to pursue his
journey minus his merchandise, and greatly cast down at the loss,
which he merited for his griping effrontery, and for the poltroonery
with which, a few days before, he had deviated from his direct road
on the rude demand of some Kourds, who sought to pick a quarrel
with him—a sort of wolf-and-lamb business—for riding through their
pastures. He forgot his loss, however, when reckoning at Tabriz the
full sack of sounding gold tomauns received for carriage of goods;
and in the joy of his heart he even condescended to speak to Dr
Wagner, and to extend to him his forgiveness for having refused to
be imposed upon, so that they parted in amity at last.
Tabriz, in size the second, in population the first city of the Persian
empire, was the limit of Dr Wagner’s travels in an easterly direction.
Thence he made excursions; and finally, turning his steps
southwards, made the circuit of that extremity of Lake Urumia, and
so got back to Bayasid in Turkish Armenia; so that he visited, in fact,
but a nook of Persia—including, however, one of its most important
cities and some rarely-explored districts. His first visit at Tabriz was
to Mr Bonham, the English consul-general, with whom he found a
Maltese physician, Dr Cassolani—then the only European medical
man resident in the place—who offered him, in the kindest manner,
an apartment in his house. Here Dr Wagner interpolates a gentle
stricture on British hospitality in Asia. Mr Bonham, he says, “was
certainly also very obliging, but seemed less hospitable; and although
he had a very roomy house and a very small family, he, like his
colleague, Mr Brant at Erzroum, was not fond of putting himself out
of his way. I confess that I have not formed the most favourable
opinion of English hospitality in the East. My letters from Lord
Aberdeen and Sir Stratford Canning had not the effect which might
have been reasonably expected from the high position of those
statesmen. In Russian Asia, less exalted recommendations generally
procured me a friendly and truly hospitable reception. On better
acquaintance, and after repeated interviews, the dry, thoroughly
English reserve and formal manner gave way, in Mr Bonham, to a
certain degree of amiability. He took a particularly warm interest in
my communications from the Caucasus, and gave me in return
valuable information concerning Persian matters. Mr Bonham was
married to a niece of Sir Robert Peel’s, a beautiful, amiable, and
accomplished lady.”
In Dr Cassolani’s house Dr Wagner made the acquaintance of a
great number of Persians, who besieged the learned hekim for
advice, and he thus had excellent opportunities of noting the
peculiarities of Persian character, manners, and morals. But the most
favourable place for the pursuit of such studies, on a large scale, he
found to be the Tabriz bazaar, which is composed of a number of
bazaars, or spacious halls full of shops. Thither daily repaired Dr
Wagner, escorted by one of Dr Cassolani’s Persian servants, a fellow
of herculean proportions, whose duty it was to open a passage
through the curious crowd which at first thronged round the
European. Here were displayed prodigious masses of merchandise,
chiefly English, only the coarser kinds of goods coming from
Germany and Russia, glass from Austria, amber from
Constantinople. Here were children’s watches from Nuremberg, with
a locomotive on the dial, and the inscription, “Railway from
Nuremberg to Furth;” lithographed likenesses of the Shah of Persia,
taken and printed in Germany; snuff-boxes from Astrakan, with the
Emperor Nicholas’s portrait; and portraits of Benkendorf,
Paskewitch, Neidhard, and other Russian generals distinguished in
recent wars. There were shawls and carpets from Hindostan, and
sabre-blades, of wonderful temper and finish, from Shiraz. Of these
latter Dr Wagner saw some, adorned with beautiful arabesque
designs in gold, and inscribed with passages from the Koran, whose
price was two hundred tomauns, or Persian ducats. Made of strips of
metal, hammered together cold, these excellent blades are the result
of prodigious labour, much time, and great skill. The chief value of
such weapons is usually in the steel, for the hilt and mounting must
be unusually rich to exceed the cost of the blade itself. Hitherto the
armourers of Tabriz, Teheran, and Ispahan have vainly endeavoured
to rival those of Shiraz.
Dr Wagner soon found himself at home in the European circle at
Tabriz, which consists chiefly of the members of the Russian and
English consulates, and of the managers of four Greek commercial
houses, branches of Constantinople establishments. The English
consul-general, as already hinted, lived rather retired, gave a dinner
or two each half-year to the Europeans, and took but small share in
the pleasures and amusements after which most of them eagerly ran.
An old Greek gentleman, named Morfopulo, was the great Lucullus
and Amphitryon of the place. Introduced to him by his Maltese
friend, Dr Wagner was at once cordially invited to a dinner, which
gave him the first idea of the sumptuous manner of living of
Europeans in Tabriz. Nothing was spared; Oriental delicacies were
embalmed and ennobled by the refinements of Western art. There
were fish from the Caspian, game from the forests of Ghilan, grapes
and mulberries from Azerbijan, the most exquisite pasties, and the
cream of the vineyards of Champagne cooling in abundant ice. The
guests were as motley, the talk as various, as the viands. From East
to West, from Ispahan to Paris, the conversation rolled. The Russian
Consul-general sketched the Persian court at Teheran; Dr Cassolani
gave verbal extracts from his life and experience at Erzroum and
Tabriz; an Italian quack, who had just arrived, and who had long led
a roving existence in Asiatic Turkey—professing alternately to
discover gold mines, and to heal all maladies by an infallible elixir—
related his adventures amongst the Kourds; whilst a young Greek
diplomatist, named Mavrocordato—a relation of the statesman of
that name—just transferred, to his no small regret, from Paris to
Tabriz, was eloquent concerning the balls, beauties, and delights of
the French capital.
The domestic arrangements of the European residents in Tabriz
are peculiar, and may possibly account for the limited nature of the
intercourse maintained with them by the gentleman who filled the
post of British consul-general at the time of Dr Wagner’s visit. Some
of the managers of the Greek houses—few of whom remain more
than half-a-dozen years, which time, owing to the profitable nature
of the trade, and especially of the smuggling traffic with the trans-
Caucasian provinces of Russia, usually suffices to make their
fortunes—were married, but had left their wives in Constantinople.
Most of them, as well as the members of the Russian consulate-
general, were bachelors. All, however, whether married or single, had
conformed to the custom of the place, by contracting limited
matrimony with Nestorian women. This Christian sect, numerous in
Azerbijan, entertains a strong partiality for Europeans, and has no
scruple, either moral or religious, in marrying its daughters to them
for a fixed term of years, and in consideration of a stipulated sum.
There is great competition for a new-comer from Europe, especially
if he be rich. The queer contract is known in Tabriz as matrimonio
alla carta. Very often the whole of the lady’s family take up their
abode in the house of the temporary husband, and live at his charges;
and this is indeed often a condition of the bargain. The usage is of
such long standing amongst Europeans in Persia, and especially in
that particular province, that it there scandalises no one. Every
European has a part of his house set aside for the women, and calls it
his harem: the ladies preserve their Persian garb and manner of life,
cover their faces before strangers and in the streets, frequent the
bath, and pass their time in dressing themselves, just like the
Mahomedan Persians. Handsome, but totally uneducated and
unintellectual, they make faithful wives and tender mothers, but
poor companions. When the term stipulated in the contract expires,
and if it be not renewed, they find no difficulty in contracting
permanent marriages with their own countrymen; the less so, that, in
such cases, they take a dowry with them, whereas, in general, the
Nestorian has to purchase his wife from her parents. The children of
the European marriage almost always remain in possession of the
mother; and Dr Wagner was assured that she testifies even stronger
affection for them than for those of her second and more regular
marriage; whilst the stepfather rarely neglects his duty towards
them. “Still more remarkable is it,” continues the Doctor, “that the
European fathers, when recalled to their own country, abandon their
children, without, as it would seem, the slightest scruple of
conscience, to a most uncertain fate, and trouble themselves no
further concerning them. But a single instance is known to me, when
a wealthy European took one of his children away with him. Even in
the case of men otherwise of high character and principle, a
prolonged residence in the East seems very apt gradually to stifle the
voice of nature, of honour, and of conscience.”
Dismissing, with this reflection, the consideration of European
society and habits in Persia, Dr Wagner turns his attention to the
natives, and to an examination of the curious incidents and
vicissitudes of modern Persian history, to which he allots an
interesting chapter—based partly on his many conversations with
British and Russian diplomatic agents, with French officers who had
served in Persia, and with French and American missionaries, partly
on the works of various English travellers—and then commences his
wanderings and explorations in the mountains of Sahant, and along
the shores of Lake Urumiah. In these and other investigations,
occupying his second volume, the length to which our notice of his
first has insensibly extended forbids our accompanying him, at least
for the present. Judging from the great number of books relating to
Western Asia that have of late years been published in this country—
many of them with marked success—the number of readers who take
an interest in that region must be very considerable. By such of them
as read German, Dr Wagner’s series of six volumes will be prized as a
mine of entertainment and information.
KATIE STEWART.
A TRUE STORY.
Sweet, clear, and full is little Katie’s voice, and she leans forward,
with her bright eyes dwelling kindly on Lady Anne’s face, while, with
affectionate pleasure, the good Lady Anne sits still, and works, and
listens—the sweet child’s voice, in which there is still scarcely a
graver modulation to tell of the coming woman, echoing into the
generous gentle heart which scarcely all its life has had a selfish
thought to interrupt the simple beautiful admiration of its unenvious
love.
“Katie, ye little cuttie!” exclaimed the horror-stricken mother,
looking in at the door.
Katie started; but it was only with privileged boldness to look up
smilingly into her mother’s face, as she finished the last verse of her
song.
“Eh, Lady Anne, what can I say to you?” said Mrs Stewart, coming
forward with indignant energetic haste; “or what will your ladyship
say to that forward monkey? Katie, have I no admonished ye to get
the manners of a serving lassie at your peril, however grand the folk
were ye saw; but, nevertheless, to gie honour where honour is due, as
it’s commanded. I think shame to look ye in the face, Lady Anne,
after hearing a bairn of mine use such a freedom.”
“But you have no need, Mrs Stewart,” said Lady Anne, “for Katie is
at home.”
There was the slightest possible tone of authority in the words,
gentle as they were; and Mrs Stewart felt herself put down.
“Weel, your ladyship kens best; but I came to speak about Katie,
Lady Anne. I’m thinking I’ll need to bring her hame.”
Mrs Stewart had her revenge. Lady Anne’s quiet face grew red and
troubled, and she struggled to loose herself from her bondage, and
turn round to face the threatening visitor.
“To take Katie home?—away from me? Oh, Mrs Stewart, dinna!”
said Lady Anne, forgetting that she was no longer a child.
“Ye see, my lady, our Isabell is to be married. The young man is
Philip Landale of Kilbrachmont. Ye may have heard tell of him even
in the Castle;—a lad with a guid house and plenty substance to take
hame a wife to; and a guid wife he’ll get to them, though maybe I
shouldna say it. And so you see, Lady Anne, I’ll be left with only
Janet at hame.”
“But, Mrs Stewart, Katie has not been accustomed to it; she could
not do you any good,” said the eager, injudicious Lady Anne.
“The very words, my lady—the very thing I said to our guidman
and the bairns at hame. ‘It’s time,’ says I, ‘that Katie was learnin’
something fit for her natural place and lot. What kind of a wife will
she ever make to a puir man, coming straight out of Kellie Castle,
and Lady Anne’s very cha’mer?’ No that I’m meaning it’s needful that
she should get a puir man, Lady Anne; but a bien man in the parish
is no like ane of your grand lords and earls; and if Katie does as weel
as her mother before her, she’ll hae a better portion than she
deserves.”
Indignantly Katie tossed her curls from her forehead, bent her
little flushed face over the frame, and began to ply her needle as if for
a wager.
“But, Mrs Stewart,” urged Lady Anne, “Katie’s birthday is not till
May, and she’s only fifteen then. Never mind the man—there’s plenty
time; but as long as we’re at Kellie, and not far away from you, Mrs
Stewart, why should not Katie live all her life with me?”
Katie glanced up archly, saucily, but said nothing.
“It wouldna be right, my lady. In the first place, you’ll no be aye at
Kellie; you’ll get folk you like better than Katie Stewart; and Katie
must depend on naebody’s will and pleasure. I’ll have it said of nae
bairn of mine that she sorned on a stranger. Na, she must come
hame.”
Lady Anne’s eyes filled with tears. The little proud belligerent
mother stood triumphant and imperious before the fire. The petulant
wilful favourite pouted over her frame; and Lady Anne looked from
one to the other with overflowing eyes.
“My sister Betty’s away, and my sister Janet’s away,” said Anne
Erskine sadly; “I’ve nobody but Katie now. If you take Katie away,
Mrs Stewart, I’ll break my heart.”
Little Katie put away her frame without saying a word, and coming
silently to the side of the high chair, knelt down, and looked
earnestly into Lady Anne’s drooping face. There was some wonder in
the look—a little awe—and then she laid down her soft cheek upon
that hand of Lady Anne’s, on which already some tears had fallen,
and taking the other hand into her own, continued to look up with a
strange, grave, sudden apprehension of the love which had been
lavished on her so long. Anne Erskine’s tears fell softly on the earnest
uplooking face, and Mrs Stewart’s heart was melted.
“Weel, Lady Anne, it’s no my nature to do a hard thing to onybody.
Keep the cuttie; I’ll no seek her as lang as I can do without her. I gie
ye my word.”
CHAPTER IX.
The west room is in no respect changed, though three years have
passed since we saw it last. In the middle of the room stands a great
open chest, already half full of carefully packed dresses. This square
flat parcel, sewed up in a linen cover, which Katie Stewart holds in
her arms as if she could with all her heart throw it out of the window,
instead of depositing it reverently in the chest, is Lady Anne’s
embroidery; and Lady Anne herself is collecting stray silks and
needle-books into a great satin bag. They are preparing for a journey.
Lady Anne Erskine is twenty—very tall, very erect, and with a most
exceptionable carriage. From her placid quiet brow the hair is
combed up, leaving not so much as one curl to shelter or shadow a
cheek which is very soft and pale indeed, but which no one could call
beautiful, or even comely. On her thin arms she wears long black
gloves which do not quite reach the elbow, but leave a part of the arm
visible under the lace ruffles which terminate her sleeves; and her
dress is of dark rustling silk, rich and heavy, though not so spotless
and youthful as it once was. Her little apron is black, and frilled with
lace; and from its pocket peeps the corner of a bright silken huswife;
for Lady Anne is no less industrious now than when she was a girl.
Ah, saucy Katie Stewart! Eighteen years old, and still no change in
you! No gloves on the round arms which clasp that covered-up
embroidery—no huswife, but a printed broadsheet ballad, the
floating light literature of the place and time, in the pocket of your
apron—no propriety in your free rebel shoulders. And people say
there is not such another pair of merry eyes in sight of Kellie Law.
The golden hair is imprisoned now, but not so closely as Lady
Anne’s, for some little curls steal lovingly down at the side, and the
fashion of combing it up clears the open white forehead, which, in
itself, is not very high, but just in proportion to the other features of
the face. Only a little taller is the round active figure—a very little. No
one is quite sensible, indeed, that Katie has made any advance in
stature at all, except herself; and even herself scarcely hopes, now in
the maturity of eighteen, to attain another half inch.
But the little girlish spirit has been growing in those quiet years. It
was Spring with her, when Katie saw the tears of Anne Erskine for
her threatened removal, and her eyes were opened then in some
degree to an appreciation of her beautiful lot. How it was that people
loved her, followed her with watchful, solicitous affection—her,
simple little Katie Stewart—the consciousness brought a strange
thrill into her heart. One may grow vain with much admiration, but
much love teaches humility. She wondered at it in her secret heart—
smiled over it with tears—and it softened and curbed her, indulged
and wilful though she was.
But all this time, in supreme contempt Katie held the rural homage
which began to be paid to her. Simple and playful as a child in Kellie,
Katie at home, when a young farmer, or sailor, or prosperous country
tradesman, or all of them together, as happened not unfrequently,
hung shyly about the fire in the Anstruther Milton, to which the
family had now removed, watching for opportunities to recommend
themselves, was as stately and dignified as any Lady Erskine of them
all. For Katie had made up her mind. Still, “a grand gentleman,”
handsome, courtly, and accomplished, with titles and honours,
wealth and birth, wandered about, a gleaming splendid shadow,
through the castles she built every day. To gain some rich and noble
wooer, of whatever kind proved attainable, was by no means Katie’s
ambition. It was a superb imagination, which walked by her side in
her dreams, naturally clothed with the grandeur which was his due;
for Katie’s mind was not very greatly developed yet—her graver
powers—and the purple of nobility and rank draped her grand figure
with natural simplicity—a guileless ideal.
“Is Lady Betty’s house a grand place, Lady Anne?” asked Katie, as
she placed the embroidery in the chest.
“It’s in the High Street,” said Lady Anne, with some pride; “not far
from the Parliament House, Katie; but it’s not like Kellie, you know;
and you that have never been in a town, may think it close, and not
like a noble house to be in a street; but the High Street and the
Canongate are grand streets; and the house is very fine too—only
Betty is alone.”
“Is Lord Colville no at home, Lady Anne?” asked Katie.
“Lord Colville’s at the sea—he’s always at the sea—and it’s dreary
for Betty to be left alone; but when she sees us, Katie, she’ll think
she’s at Kellie again.”
“And would she be glad to think that, I wonder?” said Katie, half
under her breath.
But Lady Anne did not answer, for the good Lady Anne was
making no speculations at the moment about happiness in the
abstract, and so did not properly apprehend the question of her little
friend.
The sound of a loud step hastening up stairs startled them.
Onward it came thumping through the gallery, and a breathless voice
bore it company, singing after a very strange fashion. Voice and step
were both undoubtedly Bauby Rodger’s, and the gallery creaked
under the one, and the song came forth in gasps from the other,
making itself articulate in a stormy gust as she approached the door.
“Oh handsome Charlie Stuart!
Oh charming Charlie Stuart!
There’s no a lad in a’ the land
That’s half sae sweet as thou art!”
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com