Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
lib-ical
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
lib-ical
Commits
6b029687
Commit
6b029687
authored
Feb 21, 2017
by
Mark Stenglein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎉
🎉
It works!
🎉
🎉
parent
a7b64bc0
Pipeline
#928
passed with stage
in 16 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
20 deletions
+24
-20
src/ContentLine.ts
src/ContentLine.ts
+6
-6
src/Parameter.ts
src/Parameter.ts
+7
-4
test/ContentLine.spec.ts
test/ContentLine.spec.ts
+3
-3
test/Parameter.spec.ts
test/Parameter.spec.ts
+8
-7
No files found.
src/ContentLine.ts
View file @
6b029687
import
{
isAlpha
}
from
"
./util
"
;
import
{
ICalElement
}
from
"
./ICalElement
"
;
import
Parameter
from
"
./Parameter
"
;
const
CRLF
:
string
=
"
/r/n
"
;
function
isIamaToken
(
input
:
string
):
boolean
{
return
true
;
}
const
CRLF
:
string
=
"
\r\n
"
;
/**
* Implementation of a Content Line from RFC 5545
...
...
@@ -47,7 +44,7 @@ export default class ContentLine implements ICalElement {
/* Setters */
set
name
(
newName
:
string
)
{
if
(
isIam
aToken
(
newName
))
{
if
(
Parameter
.
isIan
aToken
(
newName
))
{
this
.
_name
=
newName
;
}
else
{
...
...
@@ -59,6 +56,9 @@ export default class ContentLine implements ICalElement {
if
(
isAlpha
(
newValue
))
{
this
.
_value
=
newValue
;
}
else
{
throw
new
TypeError
(
"
'value' must be alphabetic!
"
);
}
}
/**
...
...
@@ -82,7 +82,7 @@ export default class ContentLine implements ICalElement {
this
.
params
.
forEach
((
param
)
=>
{
outputLine
+=
"
;
"
;
outputLine
+=
param
;
outputLine
+=
param
.
generate
()
;
});
outputLine
+=
"
:
"
+
this
.
value
+
CRLF
;
...
...
src/Parameter.ts
View file @
6b029687
...
...
@@ -46,7 +46,7 @@ export default class Parameter implements ICalElement {
get
paramValues
()
{
return
this
.
paramValues
;
return
this
.
_
paramValues
;
}
...
...
@@ -73,7 +73,7 @@ export default class Parameter implements ICalElement {
this
.
_paramName
=
newName
;
}
else
{
throw
new
TypeError
(
"
Parameter must be valid ia
ma-token or x-token
"
);
throw
new
TypeError
(
"
Parameter must be valid ia
na-token or x-name
"
);
}
}
...
...
@@ -125,7 +125,7 @@ export default class Parameter implements ICalElement {
* @returns string Representation of the Parameter as defined in RFC 5545
*/
public
generate
():
string
{
let
outputString
=
this
.
paramName
;
let
outputString
=
this
.
paramName
+
"
=
"
;
/**
* Goes through each parameter value and adds it, being sure to place
* the comma for the 2nd parameter onwards.
...
...
@@ -177,7 +177,10 @@ export default class Parameter implements ICalElement {
* TODO: Implement this!
*/
public
static
isXName
(
input
:
string
):
boolean
{
return
true
;
if
(
!
(
input
.
substring
(
0
,
2
)
===
"
X-
"
))
{
return
false
;
}
return
/^
[
a-zA-Z0-9-
]
+$/
.
test
(
input
);
}
/**
...
...
test/ContentLine.spec.ts
View file @
6b029687
...
...
@@ -65,13 +65,13 @@ describe("ContentLine", () => {
it
(
"
Should have the same value as given on input
"
,
()
=>
{
const
testValue
:
string
=
"
testValue
"
;
const
testParam
:
Parameter
=
new
Parameter
(
"
name
"
,
[
testValue
]);
const
testParam
:
Parameter
=
new
Parameter
(
"
NAME
"
,
[
"
TEST
"
]);
const
testLine
:
ContentLine
=
new
ContentLine
(
"
name
"
,
[
testParam
],
testValue
);
const
result
:
string
=
testLine
.
params
[
0
].
paramValues
[
0
]
;
const
result
:
string
=
testLine
.
value
;
expect
(
result
).
to
.
be
.
equal
(
testValue
);
});
});
/*
*
describe("constructor") */
});
/* describe("constructor") */
/**
* Test `fold` static method
...
...
test/Parameter.spec.ts
View file @
6b029687
...
...
@@ -26,8 +26,11 @@ describe("Parameter", () => {
const
testName
:
string
=
"
TEST-NAME
"
;
const
testParam
:
Parameter
=
new
Parameter
(
testName
,
[
"
value1
"
]);
expect
(
testParam
).
to
.
have
.
property
(
"
paramName
"
,
"
paramValues
"
,
"
generate
"
);
expect
(
testParam
).
to
.
have
.
property
(
"
_paramName
"
);
expect
(
testParam
).
to
.
have
.
property
(
"
_paramValues
"
);
expect
(
testParam
).
to
.
have
.
property
(
"
paramName
"
);
expect
(
testParam
).
to
.
have
.
property
(
"
paramValues
"
);
expect
(
testParam
).
to
.
have
.
property
(
"
generate
"
);
});
});
...
...
@@ -99,12 +102,11 @@ describe("Parameter", () => {
const
name
:
string
=
"
!NVALID-N@ME
"
;
const
values
:
string
[]
=
[
"
value
"
];
const
testParam
:
Parameter
=
new
Parameter
(
name
,
values
);
}).
to
.
throw
(
"
param-value must either be valid paramtext or
"
+
"
quoted-string
"
);
}).
to
.
throw
(
"
Parameter must be valid iana-token or x-name
"
);
});
});
describe
(
"
paramValues
"
,
()
=>
{
describe
(
"
***
paramValues
"
,
()
=>
{
it
(
"
Correctly sets paramtext values
"
,
()
=>
{
});
...
...
@@ -132,7 +134,7 @@ describe("Parameter", () => {
* that the higher level classes can simply validate proper types and use
* the lower level generate method.
*/
describe
(
"
generate()
"
,
()
=>
{
describe
(
"
***
generate()
"
,
()
=>
{
it
(
"
Correctly generates single-valued parameters
"
,
()
=>
{
});
...
...
@@ -349,7 +351,6 @@ describe("Parameter", () => {
it
(
"
returns true for valid quoted-string
"
,
()
=>
{
const
test
:
string
=
"
\"
Test this valid quote-string!
\"
"
;
console
.
log
(
test
);
const
result
:
boolean
=
Parameter
.
isQuotedString
(
test
);
expect
(
result
).
to
.
be
.
true
;
...
...
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