oc-template-vue-compiler 1.1.9 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,13 +6,23 @@ function vueOCProviderTemplate({ viewPath, providerFunctions }) {
|
|
|
6
6
|
import { createApp } from 'vue'
|
|
7
7
|
import View from '${viewPath}';
|
|
8
8
|
|
|
9
|
+
let app = null;
|
|
10
|
+
|
|
9
11
|
function renderer(props, element, ssr) {
|
|
10
12
|
const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = props;
|
|
11
13
|
${providerFunctions}
|
|
12
14
|
|
|
13
15
|
rest.getData = getData;
|
|
14
16
|
rest.getSetting = getSetting;
|
|
15
|
-
createApp(View, rest)
|
|
17
|
+
app = createApp(View, rest)
|
|
18
|
+
app.mount(element, ssr);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
element.parentElement.unmount = () => {
|
|
22
|
+
if (app) {
|
|
23
|
+
app.unmount();
|
|
24
|
+
app = null;
|
|
25
|
+
}
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
renderer.component = View;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-template-vue-compiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Compiler for the vueJS OC template",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@vitejs/plugin-vue": "^4.5.2",
|
|
32
32
|
"oc-template-vue": "^0.1.0",
|
|
33
|
-
"oc-vite-compiler": "^4.2.
|
|
33
|
+
"oc-vite-compiler": "^4.2.9"
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"dist/**",
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@testing-library/jest-dom": "^5.16.5",
|
|
25
|
+
"@testing-library/vue": "^8.0.0",
|
|
25
26
|
"@types/testing-library__jest-dom": "^5.14.5",
|
|
26
27
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
27
28
|
"@vue/tsconfig": "^0.7.0",
|
|
28
29
|
"jsdom": "^21.1.1",
|
|
29
30
|
"oc-server": "^2.1.0",
|
|
30
|
-
"oc-template-vue-compiler": "^
|
|
31
|
+
"oc-template-vue-compiler": "^2.0.1",
|
|
31
32
|
"typescript": "5.8.2",
|
|
32
33
|
"vitest": "^0.29.7",
|
|
33
34
|
"vue": "^3.5.13",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, it, afterEach, beforeEach, expect, vi } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/vue';
|
|
3
|
+
|
|
4
|
+
import App from './App.vue';
|
|
5
|
+
|
|
6
|
+
const getData = vi.fn();
|
|
7
|
+
const getSetting = vi.fn();
|
|
8
|
+
|
|
9
|
+
describe('App - Page', () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
window.oc = { events: { on: vi.fn(), fire: vi.fn() } } as any;
|
|
12
|
+
});
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
vi.restoreAllMocks();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('Gets more data when clicking the button', () => {
|
|
18
|
+
getData.mockImplementationOnce(() => Promise.resolve({}));
|
|
19
|
+
getSetting.mockImplementationOnce(() => ({}));
|
|
20
|
+
render(App, {
|
|
21
|
+
props: {
|
|
22
|
+
firstName: 'firstName',
|
|
23
|
+
lastName: 'lastName',
|
|
24
|
+
born: 1991,
|
|
25
|
+
hobbies: [],
|
|
26
|
+
},
|
|
27
|
+
global: {
|
|
28
|
+
provide: {
|
|
29
|
+
dataProvider: {
|
|
30
|
+
firstName: 'firstName',
|
|
31
|
+
lastName: 'lastName',
|
|
32
|
+
userId: 0,
|
|
33
|
+
getData,
|
|
34
|
+
getSetting,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const extraInfoButton = screen.getByText(/Fun year fact/i);
|
|
41
|
+
expect(extraInfoButton).toBeTruthy();
|
|
42
|
+
});
|
|
43
|
+
});
|