Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
b959acc6
Commit
b959acc6
authored
Oct 04, 2022
by
steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update marked test cases
parent
486cf8bd
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
19 deletions
+28
-19
jest.config.js
web/jest.config.js
+3
-0
package.json
web/package.json
+1
-0
Memo.tsx
web/src/components/Memo.tsx
+1
-2
MemberSection.tsx
web/src/components/Settings/MemberSection.tsx
+1
-2
utils.ts
web/src/helpers/utils.ts
+4
-6
index.ts
web/src/labs/marked/index.ts
+4
-0
marked.test.ts
web/src/labs/marked/marked.test.ts
+8
-7
userService.ts
web/src/services/userService.ts
+1
-2
yarn.lock
web/yarn.lock
+5
-0
No files found.
web/jest.config.js
View file @
b959acc6
...
@@ -3,4 +3,7 @@
...
@@ -3,4 +3,7 @@
module
.
exports
=
{
module
.
exports
=
{
preset
:
"ts-jest"
,
preset
:
"ts-jest"
,
testEnvironment
:
"node"
,
testEnvironment
:
"node"
,
moduleNameMapper
:
{
"lodash-es"
:
"lodash"
,
},
};
};
web/package.json
View file @
b959acc6
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
"eslint-plugin-react"
:
"^7.27.1"
,
"eslint-plugin-react"
:
"^7.27.1"
,
"jest"
:
"^29.1.2"
,
"jest"
:
"^29.1.2"
,
"less"
:
"^4.1.1"
,
"less"
:
"^4.1.1"
,
"lodash"
:
"^4.17.21"
,
"postcss"
:
"^8.4.5"
,
"postcss"
:
"^8.4.5"
,
"prettier"
:
"2.5.1"
,
"prettier"
:
"2.5.1"
,
"tailwindcss"
:
"^3.0.18"
,
"tailwindcss"
:
"^3.0.18"
,
...
...
web/src/components/Memo.tsx
View file @
b959acc6
import
dayjs
from
"dayjs"
;
import
dayjs
from
"dayjs"
;
import
relativeTime
from
"dayjs/plugin/relativeTime"
;
import
relativeTime
from
"dayjs/plugin/relativeTime"
;
import
{
indexOf
}
from
"lodash-es"
;
import
{
memo
,
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
memo
,
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
useNavigate
}
from
"react-router-dom"
;
import
{
useNavigate
}
from
"react-router-dom"
;
...
@@ -132,7 +131,7 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -132,7 +131,7 @@ const Memo: React.FC<Props> = (props: Props) => {
const
todoElementList
=
[...(
memoContainerRef
.
current
?.
querySelectorAll
(
`span.todo-block[data-value=
${
status
}
]`
)
??
[])];
const
todoElementList
=
[...(
memoContainerRef
.
current
?.
querySelectorAll
(
`span.todo-block[data-value=
${
status
}
]`
)
??
[])];
for
(
const
element
of
todoElementList
)
{
for
(
const
element
of
todoElementList
)
{
if
(
element
===
targetEl
)
{
if
(
element
===
targetEl
)
{
const
index
=
indexOf
(
todoElementList
,
element
);
const
index
=
todoElementList
.
indexOf
(
element
);
const
tempList
=
memo
.
content
.
split
(
status
===
"DONE"
?
/-
\[
x
\]
/
:
/-
\[
\]
/
);
const
tempList
=
memo
.
content
.
split
(
status
===
"DONE"
?
/-
\[
x
\]
/
:
/-
\[
\]
/
);
let
finalContent
=
""
;
let
finalContent
=
""
;
...
...
web/src/components/Settings/MemberSection.tsx
View file @
b959acc6
import
{
isEmpty
}
from
"lodash-es"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
userService
}
from
"../../services"
;
import
{
userService
}
from
"../../services"
;
...
@@ -47,7 +46,7 @@ const PreferencesSection = () => {
...
@@ -47,7 +46,7 @@ const PreferencesSection = () => {
};
};
const
handleCreateUserBtnClick
=
async
()
=>
{
const
handleCreateUserBtnClick
=
async
()
=>
{
if
(
isEmpty
(
state
.
createUserEmail
)
||
isEmpty
(
state
.
createUserPassword
)
)
{
if
(
state
.
createUserEmail
===
""
||
state
.
createUserPassword
===
""
)
{
toastHelper
.
error
(
t
(
"message.fill-form"
));
toastHelper
.
error
(
t
(
"message.fill-form"
));
return
;
return
;
}
}
...
...
web/src/helpers/utils.ts
View file @
b959acc6
import
{
assign
,
isNull
,
isUndefined
}
from
"lodash-es"
;
export
const
isNullorUndefined
=
(
value
:
any
)
=>
{
export
const
isNullorUndefined
=
(
value
:
any
)
=>
{
return
isNull
(
value
)
||
isUndefined
(
value
)
;
return
value
===
null
||
value
===
undefined
;
};
};
export
function
getNowTimeStamp
():
number
{
export
function
getNowTimeStamp
():
number
{
...
@@ -96,7 +94,7 @@ export const getElementBounding = (element: HTMLElement, relativeEl?: HTMLElemen
...
@@ -96,7 +94,7 @@ export const getElementBounding = (element: HTMLElement, relativeEl?: HTMLElemen
};
};
if
((
relativeEl
.
tagName
!==
"BODY"
&&
relativeElPosition
===
"relative"
)
||
relativeElPosition
===
"sticky"
)
{
if
((
relativeEl
.
tagName
!==
"BODY"
&&
relativeElPosition
===
"relative"
)
||
relativeElPosition
===
"sticky"
)
{
return
assign
(
bounding
,
{
return
Object
.
assign
(
bounding
,
{
top
:
elementRect
.
top
-
relativeElRect
.
top
,
top
:
elementRect
.
top
-
relativeElRect
.
top
,
left
:
elementRect
.
left
-
relativeElRect
.
left
,
left
:
elementRect
.
left
-
relativeElRect
.
left
,
});
});
...
@@ -117,13 +115,13 @@ export const getElementBounding = (element: HTMLElement, relativeEl?: HTMLElemen
...
@@ -117,13 +115,13 @@ export const getElementBounding = (element: HTMLElement, relativeEl?: HTMLElemen
};
};
if
(
isElementFixed
(
element
))
{
if
(
isElementFixed
(
element
))
{
return
assign
(
bounding
,
{
return
Object
.
assign
(
bounding
,
{
top
:
elementRect
.
top
,
top
:
elementRect
.
top
,
left
:
elementRect
.
left
,
left
:
elementRect
.
left
,
});
});
}
}
return
assign
(
bounding
,
{
return
Object
.
assign
(
bounding
,
{
top
:
elementRect
.
top
+
scrollTop
,
top
:
elementRect
.
top
+
scrollTop
,
left
:
elementRect
.
left
+
scrollLeft
,
left
:
elementRect
.
left
+
scrollLeft
,
});
});
...
...
web/src/labs/marked/index.ts
View file @
b959acc6
...
@@ -27,6 +27,10 @@ export const marked = (markdownStr: string, blockParsers = blockElementParserLis
...
@@ -27,6 +27,10 @@ export const marked = (markdownStr: string, blockParsers = blockElementParserLis
let
matchedIndex
=
-
1
;
let
matchedIndex
=
-
1
;
for
(
const
parser
of
inlineElementParserList
)
{
for
(
const
parser
of
inlineElementParserList
)
{
if
(
parser
.
name
===
"plain text"
&&
matchedInlineParser
!==
undefined
)
{
continue
;
}
const
startIndex
=
markdownStr
.
search
(
parser
.
regex
);
const
startIndex
=
markdownStr
.
search
(
parser
.
regex
);
const
matchedLength
=
match
(
markdownStr
,
parser
.
regex
);
const
matchedLength
=
match
(
markdownStr
,
parser
.
regex
);
...
...
web/src/labs/marked/marked.test.ts
View file @
b959acc6
import
{
describe
,
expect
,
test
}
from
"@jest/globals"
;
import
{
describe
,
expect
,
test
}
from
"@jest/globals"
;
import
{
unescape
}
from
"lodash-es"
;
import
{
marked
}
from
"."
;
import
{
marked
}
from
"."
;
describe
(
"test marked parser"
,
()
=>
{
describe
(
"test marked parser"
,
()
=>
{
...
@@ -27,7 +28,7 @@ console.log("hello world!")
...
@@ -27,7 +28,7 @@ console.log("hello world!")
];
];
for
(
const
t
of
tests
)
{
for
(
const
t
of
tests
)
{
expect
(
marked
(
t
.
markdown
)).
toBe
(
t
.
want
);
expect
(
unescape
(
marked
(
t
.
markdown
)
)).
toBe
(
t
.
want
);
}
}
});
});
test
(
"parse todo list block"
,
()
=>
{
test
(
"parse todo list block"
,
()
=>
{
...
@@ -43,7 +44,7 @@ console.log("hello world!")
...
@@ -43,7 +44,7 @@ console.log("hello world!")
];
];
for
(
const
t
of
tests
)
{
for
(
const
t
of
tests
)
{
expect
(
marked
(
t
.
markdown
)).
toBe
(
t
.
want
);
expect
(
unescape
(
marked
(
t
.
markdown
)
)).
toBe
(
t
.
want
);
}
}
});
});
test
(
"parse list block"
,
()
=>
{
test
(
"parse list block"
,
()
=>
{
...
@@ -59,7 +60,7 @@ console.log("hello world!")
...
@@ -59,7 +60,7 @@ console.log("hello world!")
];
];
for
(
const
t
of
tests
)
{
for
(
const
t
of
tests
)
{
expect
(
marked
(
t
.
markdown
)).
toBe
(
t
.
want
);
expect
(
unescape
(
marked
(
t
.
markdown
)
)).
toBe
(
t
.
want
);
}
}
});
});
test
(
"parse inline element"
,
()
=>
{
test
(
"parse inline element"
,
()
=>
{
...
@@ -71,7 +72,7 @@ console.log("hello world!")
...
@@ -71,7 +72,7 @@ console.log("hello world!")
];
];
for
(
const
t
of
tests
)
{
for
(
const
t
of
tests
)
{
expect
(
marked
(
t
.
markdown
)).
toBe
(
t
.
want
);
expect
(
unescape
(
marked
(
t
.
markdown
)
)).
toBe
(
t
.
want
);
}
}
});
});
test
(
"parse plain link"
,
()
=>
{
test
(
"parse plain link"
,
()
=>
{
...
@@ -83,7 +84,7 @@ console.log("hello world!")
...
@@ -83,7 +84,7 @@ console.log("hello world!")
];
];
for
(
const
t
of
tests
)
{
for
(
const
t
of
tests
)
{
expect
(
marked
(
t
.
markdown
)).
toBe
(
t
.
want
);
expect
(
unescape
(
marked
(
t
.
markdown
)
)).
toBe
(
t
.
want
);
}
}
});
});
test
(
"parse inline code"
,
()
=>
{
test
(
"parse inline code"
,
()
=>
{
...
@@ -95,7 +96,7 @@ console.log("hello world!")
...
@@ -95,7 +96,7 @@ console.log("hello world!")
];
];
for
(
const
t
of
tests
)
{
for
(
const
t
of
tests
)
{
expect
(
marked
(
t
.
markdown
)).
toBe
(
t
.
want
);
expect
(
unescape
(
marked
(
t
.
markdown
)
)).
toBe
(
t
.
want
);
}
}
});
});
test
(
"parse bold and em text"
,
()
=>
{
test
(
"parse bold and em text"
,
()
=>
{
...
@@ -119,7 +120,7 @@ console.log("hello world!")
...
@@ -119,7 +120,7 @@ console.log("hello world!")
];
];
for
(
const
t
of
tests
)
{
for
(
const
t
of
tests
)
{
expect
(
marked
(
t
.
markdown
)).
toBe
(
t
.
want
);
expect
(
unescape
(
marked
(
t
.
markdown
)
)).
toBe
(
t
.
want
);
}
}
});
});
});
});
web/src/services/userService.ts
View file @
b959acc6
import
{
isUndefined
}
from
"lodash-es"
;
import
{
locationService
}
from
"."
;
import
{
locationService
}
from
"."
;
import
*
as
api
from
"../helpers/api"
;
import
*
as
api
from
"../helpers/api"
;
import
store
from
"../store"
;
import
store
from
"../store"
;
...
@@ -58,7 +57,7 @@ const userService = {
...
@@ -58,7 +57,7 @@ const userService = {
},
},
isVisitorMode
:
()
=>
{
isVisitorMode
:
()
=>
{
return
!
isUndefined
(
userService
.
getUserIdFromPath
()
);
return
!
(
userService
.
getUserIdFromPath
()
===
undefined
);
},
},
getUserIdFromPath
:
()
=>
{
getUserIdFromPath
:
()
=>
{
...
...
web/yarn.lock
View file @
b959acc6
...
@@ -2927,6 +2927,11 @@ lodash.merge@^4.6.2:
...
@@ -2927,6 +2927,11 @@ lodash.merge@^4.6.2:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
loose-envify@^1.1.0, loose-envify@^1.4.0:
loose-envify@^1.1.0, loose-envify@^1.4.0:
version "1.4.0"
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
...
...
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