This repository was archived by the owner on Dec 9, 2022. It is now read-only.
forked from Marak/javascript-fu
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetFu.js
More file actions
99 lines (95 loc) · 2.46 KB
/
Copy pathgetFu.js
File metadata and controls
99 lines (95 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var vows = require('../vows/lib/vows'),
assert = require('assert');
var sys = require('sys');
var format = require('../index');
vows.describe('format.js lib/getFu').addVows({
"getKeys()": {
topic: {key1: "87", key2: 87, key3: 98},
"extracted keys":function( f ){
var result = format.getFu.getKeys( f );
if( result.join(", ") == "key1, key2, key3" ){
assert.ok( true );
}
else{
assert.ok( false, '"' + result.join(", ") + '"' + ' are not the keys');
}
}
},
"getValues()": {
topic: {key1: "87", key2: 87, key3: 98},
"extracted values":function( f ){
var result = format.getFu.getValues( f );
if( result.join(", ") == "87, 87, 98" ){
assert.ok( true );
}
else{
assert.ok( false, '"' + result.join(", ") + '"' + ' are not the values');
}
}
},
"getFirst()": {
"on an Array":{
topic: [1,2,3],
"got first value":function( f ){
var result = format.getFu.getFirst( f );
if( result == 1 ){
assert.ok( true );
}
else{
assert.ok( false, '"' + result.join(", ") + '"' + ' is not the first value');
}
}
},
"on a string":{
topic:' [1,2,3]',
"got null":function( f ){
var result = format.getFu.getFirst( f );
if( result == null ){
assert.ok( true );
}
else{
assert.ok( false, '"' + result.join(", ") + '"' + ' is not null');
}
}
}
},
"getLast()": {
"on an Array":{
topic: [1,2,3],
"got last value":function( f ){
var result = format.getFu.getLast( f );
if( result == 3 ){
assert.ok( true );
}
else{
assert.ok( false, '"' + result.join(", ") + '"' + ' is not the first value');
}
}
},
"on a string":{
topic:' [1,2,3]',
"got null":function( f ){
var result = format.getFu.getLast( f );
if( result == null ){
assert.ok( true );
}
else{
assert.ok( false, '"' + result.join(", ") + '"' + ' is not null');
}
}
}
},
"getIndexOf()": {
"on an Array":{
topic: function(){ return format.getFu.getIndex([1,4,3], 4);},
"got index value":function( res){
if( res == 1){
assert.ok( true );
}
else{
assert.ok( false, '"' + result.join(", ") + '"' + ' is not the index');
}
}
}
}
});