File tree Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Original file line number Diff line number Diff line change 11import { mount } from '@src/helpers/test'
22import { useCookie } from '@src/vue-use-kit'
3- import { computed } from '@src/api'
43
54afterEach ( ( ) => {
65 document . cookie = ''
@@ -16,7 +15,9 @@ const testComponent = (
1615 template : `
1716 <div>
1817 <div id="cookie">{{ cookie }}</div>
19- <div id="cookieJson">{{ cookieValue1 }} - {{ cookieValue2 }}</div>
18+ <div id="cookieJson">
19+ {{ cookie && cookie.value1 }} - {{ cookie && cookie.value2 }}
20+ </div>
2021 <button id="getCookie" @click="getCookie"></button>
2122 <button id="setCookie" @click="setCookie(cookieValue)"></button>
2223 <button id="removeCookie" @click="removeCookie"></button>
@@ -29,24 +30,12 @@ const testComponent = (
2930 onMount
3031 )
3132
32- const isObj = ( objToCheck : any ) =>
33- Object . prototype . toString . call ( objToCheck ) === '[object Object]'
34-
35- const cookieValue1 = computed (
36- ( ) => isObj ( cookie . value ) && cookie . value . value1
37- )
38- const cookieValue2 = computed (
39- ( ) => isObj ( cookie . value ) && cookie . value . value2
40- )
41-
4233 return {
4334 cookie,
4435 getCookie,
4536 setCookie,
4637 removeCookie,
47- cookieValue,
48- cookieValue1,
49- cookieValue2
38+ cookieValue
5039 }
5140 }
5241} )
Original file line number Diff line number Diff line change 1+ const checkType = ( typeToCheck : any ) =>
2+ Object . prototype . toString . call ( typeToCheck )
3+
4+ export const isObj = ( objToCheck : any ) =>
5+ checkType ( objToCheck ) === '[object Object]'
You can’t perform that action at this time.
0 commit comments