Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/node_modules/vue-style-loader/test/ |
Upload File : |
import addStylesClient from '../lib/addStylesClient' import addStylesServer from '../lib/addStylesServer' const mockedList = [ [1, 'h1 { color: red; }', ''], [1, 'p { color: green; }', ''], [2, 'span { color: blue; }', ''], [2, 'span { color: blue; }', 'print'] ] test('addStylesClient (dev)', () => { const update = addStylesClient('foo', mockedList, false) assertStylesMatch(mockedList) const mockedList2 = mockedList.slice(1, 3) update(mockedList2) assertStylesMatch(mockedList2) update() expect(document.querySelectorAll('style').length).toBe(0) }) test('addStylesClient (prod)', () => { const update = addStylesClient('foo', mockedList, true) assertStylesMatch(mockedList) const mockedList2 = mockedList.slice(2) update(mockedList2) assertStylesMatch(mockedList2) update() expect(document.querySelectorAll('style').length).toBe(0) }) test('addStylesClient (dev + ssr)', () => { mockSSRTags(mockedList, 'foo') const update = addStylesClient('foo', mockedList, false) assertStylesMatch(mockedList) update() expect(document.querySelectorAll('style').length).toBe(0) }) test('addStylesClient (prod + ssr)', () => { mockProdSSRTags(mockedList, 'foo') const update = addStylesClient('foo', mockedList, true) expect(document.querySelectorAll('style').length).toBe(1) }) test('addStylesServer (dev)', () => { const context = global.__VUE_SSR_CONTEXT__ = {} addStylesServer('foo', mockedList, false) expect(context.styles).toBe( `<style data-vue-ssr-id="foo:0">h1 { color: red; }</style>` + `<style data-vue-ssr-id="foo:1">p { color: green; }</style>` + `<style data-vue-ssr-id="foo:2">span { color: blue; }</style>` + `<style data-vue-ssr-id="foo:3" media="print">span { color: blue; }</style>` ) }) test('addStylesServer (prod)', () => { const context = global.__VUE_SSR_CONTEXT__ = {} addStylesServer('foo', mockedList, true) expect(context.styles).toBe( `<style data-vue-ssr-id="foo:0 foo:1 foo:2">` + `h1 { color: red; }\np { color: green; }\nspan { color: blue; }` + `</style>` + `<style data-vue-ssr-id="foo:3" media="print">span { color: blue; }</style>` ) }) // --- helpers --- function assertStylesMatch (list) { const styles = document.querySelectorAll('style') expect(styles.length).toBe(list.length) ;[].forEach.call(styles, (style, i) => { expect(style.textContent.indexOf(list[i][1]) > -1).toBe(true) }) } function mockSSRTags (list, parentId) { list.forEach((item, i) => { const style = document.createElement('style') style.setAttribute('data-vue-ssr-id', `${parentId}:${i}`) style.textContent = item[1] if (item[2]) { style.setAttribute('media', item[2]) } document.head.appendChild(style) }) } function mockProdSSRTags (list, parentId) { const style = document.createElement('style') style.setAttribute('data-vue-ssr-id', list.map((item, i) => `${parentId}:${i}`).join(' ')) style.textContent = list.map(item => item[1]).join('\n') document.head.appendChild(style) }