Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
1d36f679
Commit
1d36f679
authored
Aug 04, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for SWITCH function
parent
bd61acb0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
cell/.unit-tests/FormulaTests.js
cell/.unit-tests/FormulaTests.js
+41
-0
No files found.
cell/.unit-tests/FormulaTests.js
View file @
1d36f679
...
...
@@ -5242,6 +5242,47 @@ $( function () {
}
);
test
(
"
Test:
\"
SWITCH
\"
"
,
function
()
{
ws
.
getRange2
(
"
A2
"
).
setValue
(
"
2
"
);
ws
.
getRange2
(
"
A3
"
).
setValue
(
"
99
"
);
ws
.
getRange2
(
"
A4
"
).
setValue
(
"
99
"
);
ws
.
getRange2
(
"
A5
"
).
setValue
(
"
2
"
);
ws
.
getRange2
(
"
A6
"
).
setValue
(
"
3
"
);
oParser
=
new
parserFormula
(
'
SWITCH(WEEKDAY(A2),1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
SWITCH(WEEKDAY(A2),1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
Monday
"
,
'
SWITCH(WEEKDAY(A2),1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
);
oParser
=
new
parserFormula
(
'
SWITCH(A3,1,"Sunday",2,"Monday",3,"Tuesday")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
SWITCH(A3,1,"Sunday",2,"Monday",3,"Tuesday")
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#N/A
"
,
'
SWITCH(A3,1,"Sunday",2,"Monday",3,"Tuesday")
'
);
oParser
=
new
parserFormula
(
'
SWITCH(A4,1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
SWITCH(A4,1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
No match
"
,
'
SWITCH(A4,1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
);
oParser
=
new
parserFormula
(
'
SWITCH(A5,1,"Sunday",7,"Saturday","weekday")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
SWITCH(A5,1,"Sunday",7,"Saturday","weekday")
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
weekday
"
,
'
SWITCH(A5,1,"Sunday",7,"Saturday","weekday")
'
);
oParser
=
new
parserFormula
(
'
SWITCH(A6,1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
SWITCH(A6,1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
Tuesday
"
,
'
SWITCH(A6,1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
);
oParser
=
new
parserFormula
(
'
SWITCH(122,1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
SWITCH(122,1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
No match
"
,
'
SWITCH(122,1,"Sunday",2,"Monday",3,"Tuesday","No match")
'
);
oParser
=
new
parserFormula
(
'
SWITCH({1,"2asd",3},{12,2,3},{"asd",2,3,4})
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
SWITCH({1,"2asd",3},{12,2,3},{"asd",2,3,4})
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#N/A
"
,
'
SWITCH({1,"2asd",3},{12,2,3},{"asd",2,3,4})
'
);
oParser
=
new
parserFormula
(
'
SWITCH({"asd1","2asd",3},{"asd1",1,3},"sdf")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
SWITCH({"asd1","2asd",3},{"asd1",1,3},"sdf")
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
sdf
"
,
'
SWITCH({"asd1","2asd",3},{"asd1",1,3},"sdf")
'
);
}
);
test
(
"
Test:
\"
VAR
\"
"
,
function
()
{
function
_var
(
x
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment