ninjs 0.16.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -2
- data/.gitmodules +0 -0
- data/README.md +5 -7
- data/VERSION +1 -1
- data/lib/ninjs/dependencies.rb +2 -0
- data/lib/ninjs/manifest.rb +1 -1
- data/lib/ninjs/project.rb +25 -12
- data/ninjs.gemspec +31 -24
- data/repository/ninjs/.travis.yml +2 -0
- data/repository/ninjs/Gemfile +4 -0
- data/repository/ninjs/README.md +4 -0
- data/repository/ninjs/Rakefile +18 -0
- data/repository/ninjs/spec/index.html +56 -0
- data/repository/ninjs/spec/javascripts/application_spec.js +21 -0
- data/repository/ninjs/spec/javascripts/array_utility_spec.js +49 -0
- data/repository/ninjs/spec/javascripts/existence_spec.js +71 -0
- data/repository/ninjs/spec/javascripts/extension_spec.js +22 -0
- data/repository/ninjs/spec/javascripts/module_spec.js +30 -0
- data/repository/ninjs/spec/javascripts/string_utility_spec.js +85 -0
- data/repository/ninjs/spec/javascripts/support/jasmine.yml +75 -0
- data/repository/ninjs/spec/javascripts/support/jasmine_config.rb +23 -0
- data/repository/ninjs/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/spec/cli_spec.rb +24 -24
- data/spec/command_spec.rb +13 -13
- data/spec/dependencies_spec.rb +4 -0
- data/spec/manifest_spec.rb +1 -1
- data/spec/project_spec.rb +27 -17
- data/templates/jasmine.yml +74 -0
- data/templates/test-index.html +51 -0
- metadata +21 -14
- data/repository/ninjs/tests/application.test.js +0 -24
- data/repository/ninjs/tests/array.utilities.test.js +0 -55
- data/repository/ninjs/tests/existence.test.js +0 -64
- data/repository/ninjs/tests/extension.test.js +0 -28
- data/repository/ninjs/tests/index.html +0 -26
- data/repository/ninjs/tests/module.test.js +0 -71
- data/repository/ninjs/tests/qspec.js +0 -26
- data/repository/ninjs/tests/string.utilities.test.js +0 -85
- data/spec/testspec_spec.rb +0 -7
data/.bundle/config
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
---
|
2
|
-
|
1
|
+
---
|
2
|
+
BUNDLE_DISABLE_SHARED_GEMS: "1"
|
data/.gitmodules
ADDED
File without changes
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
Readme
|
1
|
+
Readme [![Build Status](https://secure.travis-ci.org/daytonn/ninjs.png)](http://travis-ci.org/daytonn/ninjs)
|
2
2
|
======
|
3
3
|
|
4
|
-
Current build status: [![Build Status](https://secure.travis-ci.org/daytonn/ninjs.png)](http://travis-ci.org/daytonn/ninjs)
|
5
|
-
|
6
4
|
About
|
7
5
|
-----
|
8
6
|
|
@@ -73,7 +71,7 @@ The basic functionality of a module is to encapsulate specific behavior in a nam
|
|
73
71
|
|
74
72
|
```js
|
75
73
|
(function() {
|
76
|
-
var mod =
|
74
|
+
var mod = app.add_module('hello');
|
77
75
|
|
78
76
|
//= require "../models/hello.model"
|
79
77
|
//= require "../elements/hello.elements"
|
@@ -93,7 +91,7 @@ The actions method is the main method of your module. The actions method is simp
|
|
93
91
|
The "run" method will execute the actions method when the DOM is ready to be manipulated. This is the same thing as jQuery's $(document).ready() method. If you wish to execute your modules actions as soon as the script is parsed you may call the "execute" method instead of "run":
|
94
92
|
|
95
93
|
```js
|
96
|
-
|
94
|
+
mod.execute(); // executes immediately
|
97
95
|
```
|
98
96
|
|
99
97
|
This pattern allows you to write in a literate style, making your intentions clear and methods succinct. Another advantage of wrapping your modules in a closure is that you may choose to define an alias for your application object which makes it easier to access, while avoiding creation of a global variable. To do this, simply pass in the application object as an argument to the outer function and then name the alias in the argument to the closure like so:
|
@@ -210,7 +208,7 @@ mod.dom.ready(function() {
|
|
210
208
|
Now these cached querys will be available via the elements command by passing it's name into the method like so:
|
211
209
|
|
212
210
|
```js
|
213
|
-
|
211
|
+
mod.some_method = function() {
|
214
212
|
mod.elements('message_box');
|
215
213
|
};
|
216
214
|
```
|
@@ -276,7 +274,7 @@ mod.set_data('plugin_config', {
|
|
276
274
|
If we wish to set several properties at once we can use just an object as the first argument:
|
277
275
|
|
278
276
|
```js
|
279
|
-
|
277
|
+
mod.set_data({
|
280
278
|
plugin_config: {
|
281
279
|
width: 300,
|
282
280
|
height: 250
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.16.
|
1
|
+
0.16.1
|
data/lib/ninjs/dependencies.rb
CHANGED
@@ -5,6 +5,7 @@ begin
|
|
5
5
|
require 'sprockets'
|
6
6
|
require 'fileutils'
|
7
7
|
require 'time'
|
8
|
+
require 'erb'
|
8
9
|
rescue LoadError
|
9
10
|
require 'rubygems'
|
10
11
|
require 'yaml'
|
@@ -13,4 +14,5 @@ rescue LoadError
|
|
13
14
|
require 'sprockets'
|
14
15
|
require 'fileutils'
|
15
16
|
require 'time'
|
17
|
+
require 'erb'
|
16
18
|
end
|
data/lib/ninjs/manifest.rb
CHANGED
data/lib/ninjs/project.rb
CHANGED
@@ -37,7 +37,8 @@ module Ninjs
|
|
37
37
|
create_ninjs_lib_file
|
38
38
|
create_utility_lib_file
|
39
39
|
create_ninjs_application_file
|
40
|
-
|
40
|
+
import_rakefile
|
41
|
+
import_spec_files
|
41
42
|
end
|
42
43
|
|
43
44
|
def create_project_scaffold
|
@@ -80,18 +81,30 @@ module Ninjs
|
|
80
81
|
file << "\nvar #{@config.name} = new NinjsApplication();"
|
81
82
|
end
|
82
83
|
end
|
83
|
-
|
84
|
-
def
|
85
|
-
FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/
|
86
|
-
FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/application.test.js", "#{@root}/tests"
|
87
|
-
FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/array.utilities.test.js", "#{@root}/tests"
|
88
|
-
FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/existence.test.js", "#{@root}/tests"
|
89
|
-
FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/extension.test.js", "#{@root}/tests"
|
90
|
-
FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/module.test.js", "#{@root}/tests"
|
91
|
-
FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/qspec.js", "#{@root}/tests"
|
92
|
-
FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/string.utilities.test.js", "#{@root}/tests"
|
84
|
+
|
85
|
+
def import_rakefile
|
86
|
+
FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/Rakefile", "#{@root}/Rakefile"
|
93
87
|
end
|
94
|
-
|
88
|
+
|
89
|
+
def import_spec_files
|
90
|
+
{
|
91
|
+
'repository/ninjs/spec/javascripts/application_spec.js' => 'spec/javascripts/',
|
92
|
+
'repository/ninjs/spec/javascripts/array_utility_spec.js' => 'spec/javascripts/',
|
93
|
+
'repository/ninjs/spec/javascripts/existence_spec.js' => 'spec/javascripts/',
|
94
|
+
'repository/ninjs/spec/javascripts/extension_spec.js' => 'spec/javascripts/',
|
95
|
+
'repository/ninjs/spec/javascripts/module_spec.js' => 'spec/javascripts/',
|
96
|
+
'repository/ninjs/spec/javascripts/string_utility_spec.js' => 'spec/javascripts/',
|
97
|
+
'repository/ninjs/spec/javascripts/support/jasmine_config.rb' => 'spec/javascripts/support',
|
98
|
+
'repository/ninjs/spec/javascripts/support/jasmine_runner.rb' => 'spec/javascripts/support',
|
99
|
+
'templates/test-index.html' => 'spec/index.html',
|
100
|
+
'templates/jasmine.yml' => 'spec/javascripts/support/'
|
101
|
+
}.each { |src, dest| import_spec_file src, dest }
|
102
|
+
end
|
103
|
+
|
104
|
+
def import_spec_file(src, dest)
|
105
|
+
FileUtils.cp "#{Ninjs::BASE_DIR}/#{src}", "#{@root}/#{dest}"
|
106
|
+
end
|
107
|
+
|
95
108
|
def update
|
96
109
|
get_modules
|
97
110
|
compile_modules
|
data/ninjs.gemspec
CHANGED
@@ -4,21 +4,22 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.16.
|
7
|
+
s.name = "ninjs"
|
8
|
+
s.version = "0.16.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
15
|
-
s.executables = [
|
11
|
+
s.authors = ["Dayton Nolan"]
|
12
|
+
s.date = "2011-10-21"
|
13
|
+
s.description = "Ninjs is a ruby application and small javascript framework that helps you build clean, modular javascript applications. Ninjs encourages \"Good Parts\" best practices and the Crockford school Module pattern (http://www.crockford.com/). The ninjs command line application is an automatic compiler, written in ruby, and based on the Sprockets library (http://getsprockets.org/)."
|
14
|
+
s.email = "daytonn@gmail.com"
|
15
|
+
s.executables = ["ninjs"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE",
|
18
18
|
"README.md"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
21
|
".bundle/config",
|
22
|
+
".gitmodules",
|
22
23
|
".travis.yml",
|
23
24
|
"CNAME",
|
24
25
|
"Gemfile",
|
@@ -114,6 +115,10 @@ Gem::Specification.new do |s|
|
|
114
115
|
"repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_888888_256x240.png",
|
115
116
|
"repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_cd0a0a_256x240.png",
|
116
117
|
"repository/jquery/ui/latest.js",
|
118
|
+
"repository/ninjs/.travis.yml",
|
119
|
+
"repository/ninjs/Gemfile",
|
120
|
+
"repository/ninjs/README.md",
|
121
|
+
"repository/ninjs/Rakefile",
|
117
122
|
"repository/ninjs/core/.core.pdoc.yaml",
|
118
123
|
"repository/ninjs/core/.existence.pdoc.yaml",
|
119
124
|
"repository/ninjs/core/.extend.pdoc.yaml",
|
@@ -125,14 +130,16 @@ Gem::Specification.new do |s|
|
|
125
130
|
"repository/ninjs/core/module.js",
|
126
131
|
"repository/ninjs/core/nin.js",
|
127
132
|
"repository/ninjs/extensions/jquery.elements.js",
|
128
|
-
"repository/ninjs/
|
129
|
-
"repository/ninjs/
|
130
|
-
"repository/ninjs/
|
131
|
-
"repository/ninjs/
|
132
|
-
"repository/ninjs/
|
133
|
-
"repository/ninjs/
|
134
|
-
"repository/ninjs/
|
135
|
-
"repository/ninjs/
|
133
|
+
"repository/ninjs/spec/index.html",
|
134
|
+
"repository/ninjs/spec/javascripts/application_spec.js",
|
135
|
+
"repository/ninjs/spec/javascripts/array_utility_spec.js",
|
136
|
+
"repository/ninjs/spec/javascripts/existence_spec.js",
|
137
|
+
"repository/ninjs/spec/javascripts/extension_spec.js",
|
138
|
+
"repository/ninjs/spec/javascripts/module_spec.js",
|
139
|
+
"repository/ninjs/spec/javascripts/string_utility_spec.js",
|
140
|
+
"repository/ninjs/spec/javascripts/support/jasmine.yml",
|
141
|
+
"repository/ninjs/spec/javascripts/support/jasmine_config.rb",
|
142
|
+
"repository/ninjs/spec/javascripts/support/jasmine_runner.rb",
|
136
143
|
"repository/ninjs/utilities/all.js",
|
137
144
|
"repository/ninjs/utilities/array.js",
|
138
145
|
"repository/ninjs/utilities/cookie.js",
|
@@ -176,14 +183,15 @@ Gem::Specification.new do |s|
|
|
176
183
|
"spec/notification_spec.rb",
|
177
184
|
"spec/project_spec.rb",
|
178
185
|
"spec/spec_helper.rb",
|
179
|
-
"
|
186
|
+
"templates/jasmine.yml",
|
187
|
+
"templates/test-index.html"
|
180
188
|
]
|
181
|
-
s.homepage =
|
182
|
-
s.licenses = [
|
183
|
-
s.require_paths = [
|
184
|
-
s.rubyforge_project =
|
185
|
-
s.rubygems_version =
|
186
|
-
s.summary =
|
189
|
+
s.homepage = "http://github.com/textnotspeech/ninjs"
|
190
|
+
s.licenses = ["MIT"]
|
191
|
+
s.require_paths = ["lib"]
|
192
|
+
s.rubyforge_project = "nowarning"
|
193
|
+
s.rubygems_version = "1.8.10"
|
194
|
+
s.summary = "ninjs is a command line application to help you write clean, modular javascript applications."
|
187
195
|
s.test_files = [
|
188
196
|
"spec/cli_spec.rb",
|
189
197
|
"spec/command_spec.rb",
|
@@ -195,8 +203,7 @@ Gem::Specification.new do |s|
|
|
195
203
|
"spec/ninjs_spec.rb",
|
196
204
|
"spec/notification_spec.rb",
|
197
205
|
"spec/project_spec.rb",
|
198
|
-
"spec/spec_helper.rb"
|
199
|
-
"spec/testspec_spec.rb"
|
206
|
+
"spec/spec_helper.rb"
|
200
207
|
]
|
201
208
|
|
202
209
|
if s.respond_to? :specification_version then
|
@@ -0,0 +1,18 @@
|
|
1
|
+
begin
|
2
|
+
require 'jasmine'
|
3
|
+
load 'jasmine/tasks/jasmine.rake'
|
4
|
+
rescue LoadError
|
5
|
+
task :jasmine do
|
6
|
+
abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
task :travis do
|
11
|
+
["rake jasmine:ci"].each do |cmd|
|
12
|
+
puts "Starting to run #{cmd}..."
|
13
|
+
system("export DISPLAY=:99.0 && bundle exec #{cmd}")
|
14
|
+
raise "#{cmd} failed!" unless $?.exitstatus == 0
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => 'travis'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Jasmine Spec Runner: Ninjs</title>
|
6
|
+
|
7
|
+
<link rel="shortcut icon" type="image/png" href="https://s3.amazonaws.com/daytonn-js/jamsine-1.1.0/jasmine_favicon.png">
|
8
|
+
<link rel="stylesheet" href="https://s3.amazonaws.com/daytonn-js/jamsine-1.1.0/jasmine.css" />
|
9
|
+
<script src="https://s3.amazonaws.com/daytonn-js/jamsine-1.1.0/jasmine.js"></script>
|
10
|
+
<script src="https://s3.amazonaws.com/daytonn-js/jamsine-1.1.0/jasmine-html.js"></script>
|
11
|
+
|
12
|
+
<!-- NinJs source files -->
|
13
|
+
<script type="text/javascript" src="../core/existence.js"></script>
|
14
|
+
<script type="text/javascript" src="../core/extend.js"></script>
|
15
|
+
<script type="text/javascript" src="../core/application.js"></script>
|
16
|
+
<script type="text/javascript" src="../core/dom.js"></script>
|
17
|
+
<script type="text/javascript" src="../core/module.js"></script>
|
18
|
+
<script type="text/javascript" src="../utilities/string.js"></script>
|
19
|
+
<script type="text/javascript" src="../utilities/array.js"></script>
|
20
|
+
|
21
|
+
<!-- spec files -->
|
22
|
+
<script src="javascripts/existence_spec.js"></script>
|
23
|
+
<script src="javascripts/extension_spec.js"></script>
|
24
|
+
<script src="javascripts/application_spec.js"></script>
|
25
|
+
<script src="javascripts/module_spec.js"></script>
|
26
|
+
<script src="javascripts/array_utility_spec.js"></script>
|
27
|
+
<script src="javascripts/string_utility_spec.js"></script>
|
28
|
+
|
29
|
+
<script type="text/javascript">
|
30
|
+
(function() {
|
31
|
+
var jasmineEnv = jasmine.getEnv();
|
32
|
+
var trivialReporter = new jasmine.TrivialReporter();
|
33
|
+
var currentWindowOnload = window.onload;
|
34
|
+
|
35
|
+
jasmineEnv.updateInterval = 1000;
|
36
|
+
jasmineEnv.addReporter(trivialReporter);
|
37
|
+
jasmineEnv.specFilter = function(spec) {
|
38
|
+
return trivialReporter.specFilter(spec);
|
39
|
+
};
|
40
|
+
|
41
|
+
window.onload = function() {
|
42
|
+
if (currentWindowOnload) {
|
43
|
+
currentWindowOnload();
|
44
|
+
}
|
45
|
+
execJasmine();
|
46
|
+
};
|
47
|
+
|
48
|
+
function execJasmine() {
|
49
|
+
jasmineEnv.execute();
|
50
|
+
}
|
51
|
+
|
52
|
+
})();
|
53
|
+
</script>
|
54
|
+
</head>
|
55
|
+
<body></body>
|
56
|
+
</html>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
describe("NinjsApplication", function() {
|
2
|
+
var app;
|
3
|
+
|
4
|
+
beforeEach(function() {
|
5
|
+
app = new NinjsApplication('myapp');
|
6
|
+
});
|
7
|
+
|
8
|
+
afterEach(function() {
|
9
|
+
app = undefined;
|
10
|
+
});
|
11
|
+
|
12
|
+
it("should create a ninjs application object", function() {
|
13
|
+
expect(is_defined(app)).toBeTruthy();
|
14
|
+
expect(is_typeof(NinjsApplication, app)).toBeTruthy();
|
15
|
+
});
|
16
|
+
|
17
|
+
it("should create a NinjsModule", function() {
|
18
|
+
app.add_module('mymod');
|
19
|
+
expect(is_typeof(NinjsModule, app.mymod)).toBeTruthy();
|
20
|
+
});
|
21
|
+
});
|
@@ -0,0 +1,49 @@
|
|
1
|
+
describe("Array Extensions", function() {
|
2
|
+
|
3
|
+
it("should test for emptiness with is_empty and not_empty", function() {
|
4
|
+
expect([].is_empty()).toBeTruthy();
|
5
|
+
expect(['one', 'two', 'three'].is_empty()).toBeFalsy();
|
6
|
+
expect(['one', 'two', 'three'].not_empty()).toBeTruthy();
|
7
|
+
expect([].not_empty()).toBeFalsy();
|
8
|
+
});
|
9
|
+
|
10
|
+
it("should iterate over each element with each", function() {
|
11
|
+
var iteration_count = 0,
|
12
|
+
test_array_values = [],
|
13
|
+
test_array_indices = [];
|
14
|
+
|
15
|
+
['one', 'two', 'three'].each(function(value, index) {
|
16
|
+
iteration_count++;
|
17
|
+
test_array_values.push(value);
|
18
|
+
test_array_indices.push(index);
|
19
|
+
});
|
20
|
+
|
21
|
+
expect(test_array_values[0]).toEqual('one');
|
22
|
+
expect(test_array_values[1]).toEqual('two');
|
23
|
+
expect(test_array_values[2]).toEqual('three');
|
24
|
+
|
25
|
+
expect(test_array_indices[0]).toEqual(0);
|
26
|
+
expect(test_array_indices[1]).toEqual(1);
|
27
|
+
expect(test_array_indices[2]).toEqual(2);
|
28
|
+
|
29
|
+
expect(iteration_count).toEqual(3);
|
30
|
+
});
|
31
|
+
|
32
|
+
it("should test if an array contains an element", function() {
|
33
|
+
var array = ['one', 'two', 'three'],
|
34
|
+
string = 'hello',
|
35
|
+
object = {
|
36
|
+
name: 'some object'
|
37
|
+
},
|
38
|
+
number = 45,
|
39
|
+
date = new Date(),
|
40
|
+
test_array = [array, string, object, number, date];
|
41
|
+
|
42
|
+
expect(test_array.contains(array)).toBeTruthy();
|
43
|
+
expect(test_array.contains(string)).toBeTruthy();
|
44
|
+
expect(test_array.contains(object)).toBeTruthy();
|
45
|
+
expect(test_array.contains(number)).toBeTruthy();
|
46
|
+
expect(test_array.contains(date)).toBeTruthy();
|
47
|
+
expect(test_array.contains('not in there')).toBeFalsy();
|
48
|
+
});
|
49
|
+
});
|
@@ -0,0 +1,71 @@
|
|
1
|
+
describe("Existence:", function() {
|
2
|
+
|
3
|
+
it("should test for existence with is_defined", function() {
|
4
|
+
var nonexistent;
|
5
|
+
var existent = 'I think';
|
6
|
+
expect(is_defined(existent)).toBeTruthy();
|
7
|
+
expect(is_defined(nonexistent)).toBeFalsy();
|
8
|
+
});
|
9
|
+
|
10
|
+
it("should test for non-existence with is_undefined", function() {
|
11
|
+
var existent = 'I think';
|
12
|
+
var nonexistent;
|
13
|
+
expect(is_undefined(nonexistent)).toBeTruthy();
|
14
|
+
expect(is_undefined(existent)).toBeFalsy();
|
15
|
+
});
|
16
|
+
|
17
|
+
it("should check for type strictly with is_typeof", function() {
|
18
|
+
var foo = function(){};
|
19
|
+
var bar = {
|
20
|
+
name: 'SomeObject',
|
21
|
+
method: function() {}
|
22
|
+
};
|
23
|
+
var SomeClass = function(){};
|
24
|
+
var some_instance = new SomeClass();
|
25
|
+
|
26
|
+
expect(is_typeof(Number, 4)).toBeTruthy();
|
27
|
+
expect(is_typeof(String, 'Hello World')).toBeTruthy();
|
28
|
+
expect(is_typeof(Array, ['one', 'two', 'three'])).toBeTruthy();
|
29
|
+
expect(is_typeof(Function, foo)).toBeTruthy();
|
30
|
+
expect(is_typeof(Object, bar)).toBeTruthy();
|
31
|
+
expect(is_typeof(RegExp, /pattern/)).toBeTruthy();
|
32
|
+
expect(is_typeof(SomeClass, some_instance)).toBeTruthy();
|
33
|
+
|
34
|
+
expect(is_typeof(Object, 4)).toBeFalsy();
|
35
|
+
expect(is_typeof(Object, 'Hello World')).toBeFalsy();
|
36
|
+
expect(is_typeof(Object, ['one', 'two', 'three'])).toBeFalsy();
|
37
|
+
expect(is_typeof(Object, foo)).toBeFalsy();
|
38
|
+
expect(is_typeof(Function, bar)).toBeFalsy();
|
39
|
+
expect(is_typeof(Object, some_instance)).toBeFalsy();
|
40
|
+
expect(is_typeof(Function, some_instance)).toBeFalsy();
|
41
|
+
});
|
42
|
+
|
43
|
+
it("should check for default types with convenience methods", function() {
|
44
|
+
var today = new Date();
|
45
|
+
var easy_as = [1,2,3];
|
46
|
+
var pattern = new RegExp(/pattern/);
|
47
|
+
|
48
|
+
expect(is_string('hello')).toBeTruthy();
|
49
|
+
expect(is_number(42)).toBeTruthy();
|
50
|
+
expect(is_array(easy_as)).toBeTruthy();
|
51
|
+
expect(is_bool(false)).toBeTruthy();
|
52
|
+
expect(is_date(today)).toBeTruthy();
|
53
|
+
expect(is_regex(pattern)).toBeTruthy();
|
54
|
+
|
55
|
+
expect(is_regex('hello')).toBeFalsy();
|
56
|
+
expect(is_date(42)).toBeFalsy();
|
57
|
+
expect(is_bool(easy_as)).toBeFalsy();
|
58
|
+
expect(is_array(today)).toBeFalsy();
|
59
|
+
expect(is_number(true)).toBeFalsy();
|
60
|
+
expect(is_string(pattern)).toBeFalsy();
|
61
|
+
});
|
62
|
+
|
63
|
+
it("should determine if a given string is numerical", function() {
|
64
|
+
expect(is_numeric(2)).toBeTruthy();
|
65
|
+
expect(is_numeric(-2)).toBeTruthy();
|
66
|
+
expect(is_numeric(45.6)).toBeTruthy();
|
67
|
+
expect(is_numeric(-45.6)).toBeTruthy();
|
68
|
+
expect(is_numeric('45.6')).toBeTruthy();
|
69
|
+
expect(is_numeric('Hello')).toBeFalsy();
|
70
|
+
});
|
71
|
+
});
|