�PNG  IHDR��;���IDATx��ܻn�0���K�� �)(�pA��� ���7�LeG{�� �§㻢|��ذaÆ 6lذaÆ 6lذaÆ 6lom��$^�y���ذag�5bÆ 6lذaÆ 6lذa{���� 6lذaÆ �`����}H�Fkm�,�m����Ӫ���ô�ô!� �x�|'ܢ˟;�E:���9�&ᶒ�}�{�v]�n&�6� �h��_��t�ڠ͵-ҫ���Z;��Z$�.�P���k�ž)�!��o���>}l�eQfJ�T��u і���چ��\��X=8��Rن4`Vw�l�>����n�G�^��i�s��"ms�$�u��i��?w�bs[m�6�K4���O���.�4��%����/����b�C%��t ��M�ז� �-l�G6�mrz2���s�%�9��s@���-�k�9�=���)������k�B5����\��+͂�Zsٲ ��Rn��~G���R���C����� �wIcI��n7jJ���hۛNCS|���j0��8y�iHKֶۛ�k�Ɉ+;Sz������L/��F�*\��Ԕ�#"5��m�2��[S��������=�g��n�a�P�e�ғ�L�� lذaÆ 6l�^k��̱aÆ 6lذaÆ 6lذa;���� �_��ذaÆ 6lذaÆ 6lذaÆ ���R���IEND�B` 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( `` + `` + `` + `` ) }) test('addStylesServer (prod)', () => { const context = global.__VUE_SSR_CONTEXT__ = {} addStylesServer('foo', mockedList, true) expect(context.styles).toBe( `` + `` ) }) // --- 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) }