Skip to content

Commit 740b51d

Browse files
committed
Added proper Qunit tests
* moved old tests to test/examples * js for tests are .gitignored; must have coffeescript to compile/run tests/contribute.
1 parent 1b97554 commit 740b51d

21 files changed

+1875
-41
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test/localize_test.js
2+
test/qunit_setup.js
3+

README.markdown

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ You can provide a callback if you want to augment or replace the default callbac
129129
}
130130
})
131131

132-
See the tests for working examples.
132+
See the test/samples for working examples.
133133

134134
# Contributing
135135

@@ -141,6 +141,10 @@ save changes to the coffee code under src/.
141141
If you're interested in contributing, please fork the [repository](https://github.com/coderifous/jquery-localize),
142142
make your changes, and send pull-requests.
143143

144+
Tests use QUnit. Run them by serving from the root of the project and
145+
navigating to the test/ directory, which has an index.html that takes it from
146+
there.
147+
144148
Learn more about [how to fork](http://help.github.com/fork-a-repo/) and
145149
[pull-requests](http://help.github.com/pull-requests/).
146150

TODO.markdown

Lines changed: 0 additions & 4 deletions
This file was deleted.

builder

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
coffee -wco build src/jquery.localize.coffee
1+
coffee -wco build src/*.coffee &
2+
coffee -wc test/*.coffee &

test/absolute_prefix_path.html renamed to test/examples/absolute_prefix_path.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
88
<title>Localize Test</title>
99
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
10-
<script src="../build/jquery.localize.js" type="text/javascript" charset="utf-8"></script>
10+
<script src="../../build/jquery.localize.js" type="text/javascript" charset="utf-8"></script>
1111
</head>
1212

1313
<body>
1414
<h1>Test localization...</h1>
15-
<p rel="localize[test.puts]">puts 2 + 2</p>
16-
<p rel="localize[test.array]">foo = %w(a b c)</p>
17-
<p rel="localize[test.iteration]">foo.each { |n| puts "Got #{n}" }</p>
18-
<p rel="localize[message]">It failed :(</p>
15+
<p rel="localize[test.nested]">puts 2 + 2</p>
16+
<p rel="localize[basic]">It failed :(</p>
1917
<script type="text/javascript" charset="utf-8">
2018
$(function(){
2119
var opts = { language: "ja", pathPrefix: "/test/lang", skipLanguage: "en-US" };

test/basic_usage.html renamed to test/examples/basic_usage.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
88
<title>Localize Test</title>
99
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
10-
<script src="../build/jquery.localize.js" type="text/javascript" charset="utf-8"></script>
10+
<script src="../../build/jquery.localize.js" type="text/javascript" charset="utf-8"></script>
1111
</head>
1212

1313
<body>
1414
<h1>Test localization...</h1>
15-
<p rel="localize[test.puts]">puts 2 + 2</p>
16-
<p rel="localize[test.array]">foo = %w(a b c)</p>
17-
<p rel="localize[test.iteration]">foo.each { |n| puts "Got #{n}" }</p>
15+
<p rel="localize[test.nested]">puts 2 + 2</p>
1816
<input rel="localize[test.input]" type="text" value="fail" />
1917
<select>
2018
<optgroup rel="localize[test.optgroup]" label="Fail">
@@ -25,10 +23,10 @@ <h1>Test localization...</h1>
2523
<img src="ruby_square.gif" alt="a square ruby" rel="localize[test.ruby_image]"/>
2624
Ruby image should be round.
2725
</p>
28-
<p rel="localize[message]">It failed :(</p>
26+
<p rel="localize[basic]">It failed :(</p>
2927
<script type="text/javascript" charset="utf-8">
3028
$(function(){
31-
var opts = { language: "ja", pathPrefix: "lang", skipLanguage: "en-US" };
29+
var opts = { language: "ja", pathPrefix: "../lang", skipLanguage: "en-US" };
3230
$("[rel*=localize]").localize("test", opts)
3331
})
3432
</script>

test/custom_callback_usage.html renamed to test/examples/custom_callback_usage.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,19 @@
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
88
<title>Localize Test</title>
99
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
10-
<script src="../build/jquery.localize.js" type="text/javascript" charset="utf-8"></script>
10+
<script src="../../build/jquery.localize.js" type="text/javascript" charset="utf-8"></script>
1111
</head>
1212

1313
<body>
1414
<h1>Test localization...</h1>
15-
<p rel="localize[test.puts]">puts 2 + 2</p>
16-
<p rel="localize[test.array]">foo = %w(a b c)</p>
17-
<p rel="localize[test.iteration]">foo.each { |n| puts "Got #{n}" }</p>
18-
<p rel="localize[message]">It failed :(</p>
15+
<p rel="localize[test.nested]">puts 2 + 2</p>
16+
<p rel="localize[basic]">It failed :(</p>
1917
<script type="text/javascript" charset="utf-8">
2018
$(function(){
21-
var opts = { language: "ja", pathPrefix: "lang", skipLanguage: "en-US" };
19+
var opts = { language: "ja", pathPrefix: "../lang", skipLanguage: "en-US" };
2220
opts.callback = function(data, defaultCallback) {
2321
data.message = "Optional call back works."
24-
$("[rel*=message]").css({color: "#FF8833"})
22+
$("[rel*=basic]").css({color: "#FF8833"})
2523
defaultCallback(data);
2624
}
2725
$("[rel*=localize]").localize("test", opts)

test/language_and_country.html renamed to test/examples/language_and_country.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,15 @@
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
88
<title>Localize Test</title>
99
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
10-
<script src="../build/jquery.localize.js" type="text/javascript" charset="utf-8"></script>
10+
<script src="../../build/jquery.localize.js" type="text/javascript" charset="utf-8"></script>
1111
</head>
1212

1313
<body>
1414
<h1>Test localization...</h1>
15-
<p rel="localize[test.puts]">puts 2 + 2</p>
16-
<p rel="localize[test.array]">foo = %w(a b c)</p>
17-
<p rel="localize[test.iteration]">foo.each { |n| puts "Got #{n}" }</p>
1815
<p rel="localize[message]">It failed :(</p>
1916
<script type="text/javascript" charset="utf-8">
2017
$(function(){
21-
var opts = { language: "ja-XX", pathPrefix: "lang", skipLanguage: "en-US" };
18+
var opts = { language: "ja-XX", pathPrefix: "../lang", skipLanguage: "en-US" };
2219
$("[rel*=localize]").localize("test", opts)
2320
})
2421
</script>
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)