Skip to content

Commit 00162f4

Browse files
authored
Merge pull request #3 from ara-framework/develop
Version 3.0
2 parents 295c338 + 868b456 commit 00162f4

File tree

11 files changed

+422
-124
lines changed

11 files changed

+422
-124
lines changed

.circleci/config.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
# specify the version you desire here
10+
- image: circleci/node:10.16
11+
12+
working_directory: ~/hypernova-vue
13+
14+
steps:
15+
- checkout
16+
17+
# Download and cache dependencies
18+
- restore_cache:
19+
keys:
20+
- v1-dependencies-{{ checksum "package.json" }}
21+
# fallback to using the latest cache if no exact match is found
22+
- v1-dependencies-
23+
24+
- run: yarn install
25+
26+
- save_cache:
27+
paths:
28+
- node_modules
29+
key: v1-dependencies-{{ checksum "package.json" }}
30+
31+
# run linter
32+
- run: yarn lint
33+
34+
# run tests
35+
- run: yarn test
36+
37+
publish:
38+
docker:
39+
# specify the version you desire here
40+
- image: circleci/node:10.16
41+
42+
working_directory: ~/hypernova-vue
43+
44+
steps:
45+
- checkout
46+
47+
# Download and cache dependencies
48+
- restore_cache:
49+
keys:
50+
- v1-dependencies-{{ checksum "package.json" }}
51+
# fallback to using the latest cache if no exact match is found
52+
- v1-dependencies-
53+
54+
- run: yarn install
55+
56+
- save_cache:
57+
paths:
58+
- node_modules
59+
key: v1-dependencies-{{ checksum "package.json" }}
60+
61+
# run linter
62+
- run: yarn semantic-release -d
63+
64+
workflows:
65+
version: 2
66+
main:
67+
jobs:
68+
- build
69+
- publish:
70+
requires:
71+
- build
72+
filters:
73+
branches:
74+
only: master

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lib
2+
node_modules

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
2+
"env": {
3+
"browser": true,
4+
"node": true,
5+
"jest": true
6+
},
27
"extends": [
8+
"plugin:@typescript-eslint/recommended",
39
"airbnb-base"
410
],
511
"rules": {

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
roots: ['<rootDir>/src'],
3+
transform: {
4+
'^.+\\.tsx?$': 'ts-jest',
5+
},
6+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
7+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
8+
};

package.json

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"name": "hypernova-vue",
3-
"version": "2.1.0",
3+
"version": "3.0.0-alpha.0",
44
"description": "Vue bindings for Hypernova",
55
"main": "lib/index.js",
6+
"types": "lib/index.d.ts",
67
"author": "Felipe Guizar Diaz <[email protected]>",
78
"scripts": {
8-
"prepublish": "npm run build",
9-
"lint": "eslint src",
10-
"build": "babel src -d lib"
9+
"lint": "eslint src/**/*.ts",
10+
"build": "tsc",
11+
"test": "jest",
12+
"semantic-release": "semantic-release"
1113
},
1214
"keywords": [
1315
"vuew",
@@ -18,16 +20,21 @@
1820
"license": "MIT",
1921
"repository": {
2022
"type": "git",
21-
"url": "git@github.com:marconi1992/hypernova-vue.git"
23+
"url": "https://github.com/ara-framework/hypernova-vue.git"
2224
},
2325
"devDependencies": {
24-
"@babel/cli": "^7.5.5",
25-
"@babel/core": "^7.5.5",
26-
"@babel/runtime": "^7.5.5",
27-
"babel-preset-airbnb": "^4.0.1",
28-
"eslint": "^5.14.1",
29-
"eslint-config-airbnb-base": "^13.1.0",
30-
"eslint-plugin-import": "^2.16.0"
26+
"@babel/runtime": "^7.6.0",
27+
"@types/jest": "^24.0.18",
28+
"@types/node": "^12.7.4",
29+
"@typescript-eslint/eslint-plugin": "^2.1.0",
30+
"@typescript-eslint/parser": "^2.1.0",
31+
"eslint": "^6.3.0",
32+
"eslint-config-airbnb-base": "^14.0.0",
33+
"eslint-plugin-import": "^2.18.2",
34+
"jest": "^24.9.0",
35+
"ts-jest": "^24.0.2",
36+
"typescript": "^3.6.0",
37+
"semantic-release": "^15.13.24"
3138
},
3239
"dependencies": {
3340
"hypernova": "^2.5.0",

server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib/server.js');

src/__test__/index.spec.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import Vue, { VNode } from 'vue';
2+
import {
3+
loadById,
4+
mountComponent,
5+
renderInPlaceholder,
6+
renderVue,
7+
} from '..';
8+
9+
describe('loadById', () => {
10+
beforeEach(() => {
11+
document.body.innerHTML = '';
12+
});
13+
14+
test('should load payload by id', () => {
15+
document.body.innerHTML = `
16+
<div data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b4"></div>
17+
<script type="application/json" data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b4"><!--{"title":"Ara Framework"}--></script>
18+
`;
19+
20+
const payload = loadById('Example', 'd0a0b082-dad0-4bf2-ae4f-08eff16575b4');
21+
22+
const { node, data } = payload;
23+
24+
expect(node.getAttribute('data-hypernova-key')).toEqual('Example');
25+
expect(node.getAttribute('data-hypernova-id')).toEqual('d0a0b082-dad0-4bf2-ae4f-08eff16575b4');
26+
expect(data).toEqual({
27+
title: 'Ara Framework',
28+
});
29+
});
30+
31+
test('should not load payload by id', () => {
32+
const payload = loadById('Example', 'd0a0b082-dad0-4bf2-ae4f-08eff16575b4');
33+
34+
expect(payload).toBeNull();
35+
});
36+
});
37+
38+
describe('mountComponent', () => {
39+
beforeEach(() => {
40+
document.body.innerHTML = '';
41+
});
42+
43+
test('should mount component correctly', () => {
44+
document.body.innerHTML = '<div id="app"><div>';
45+
46+
const app = Vue.extend({
47+
props: ['title'],
48+
render(h): VNode {
49+
return h('h1', {}, this.title);
50+
},
51+
});
52+
53+
const node = document.getElementById('app');
54+
55+
mountComponent(app, node, { title: 'Ara Framework' });
56+
57+
expect(node.innerHTML).toEqual('<h1>Ara Framework</h1>');
58+
});
59+
});
60+
61+
describe('renderInPlaceholder', () => {
62+
beforeEach(() => {
63+
document.body.innerHTML = '';
64+
});
65+
66+
test('should render component in placeholder correctly', () => {
67+
document.body.innerHTML = `
68+
<div data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b4"></div>
69+
<script type="application/json" data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b4"><!--{"title":"Ara Framework"}--></script>
70+
`;
71+
72+
const app = Vue.extend({
73+
props: ['title'],
74+
render(h): VNode {
75+
return h('h1', {}, this.title);
76+
},
77+
});
78+
79+
renderInPlaceholder('Example', app, 'd0a0b082-dad0-4bf2-ae4f-08eff16575b4');
80+
81+
const expectedHTML = `
82+
<div data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b4"><h1>Ara Framework</h1></div>
83+
<script type="application/json" data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b4"><!--{"title":"Ara Framework"}--></script>
84+
`;
85+
expect(document.body.innerHTML).toEqual(expectedHTML);
86+
});
87+
});
88+
89+
describe('renderVue', () => {
90+
beforeEach(() => {
91+
document.body.innerHTML = '';
92+
});
93+
94+
test('should render all the components in the body', () => {
95+
document.body.innerHTML = `
96+
<div data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b4"></div>
97+
<script type="application/json" data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b4"><!--{"title":"Ara Framework"}--></script>
98+
<div data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b5"></div>
99+
<script type="application/json" data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b5"><!--{"title":"Ara Framework 2"}--></script>
100+
`;
101+
102+
const app = Vue.extend({
103+
props: ['title'],
104+
render(h): VNode {
105+
return h('h1', {}, this.title);
106+
},
107+
});
108+
109+
renderVue('Example', app);
110+
111+
const expectedHTML = `
112+
<div data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b4"><h1>Ara Framework</h1></div>
113+
<script type="application/json" data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b4"><!--{"title":"Ara Framework"}--></script>
114+
<div data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b5"><h1>Ara Framework 2</h1></div>
115+
<script type="application/json" data-hypernova-key="Example" data-hypernova-id="d0a0b082-dad0-4bf2-ae4f-08eff16575b5"><!--{"title":"Ara Framework 2"}--></script>
116+
`;
117+
118+
expect(document.body.innerHTML).toEqual(expectedHTML);
119+
});
120+
});

src/index.js

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)