~repos /atoms-element

#js

git clone https://pyrossh.dev/repos/atoms-element.git

A simple web component library for defining your custom elements. It works on both client and server.


c9e71438 Peter John

4 years ago
add more tests
Files changed (3) hide show
  1. .github/workflows/main.yml +6 -21
  2. readme.md +1 -0
  3. test/index.test.js +17 -2
.github/workflows/main.yml CHANGED
@@ -1,26 +1,11 @@
1
- name: CI
1
+ name: Tests
2
2
  on: [push]
3
3
  jobs:
4
4
  build:
5
- name: Test ${{ matrix.node }} and ${{ matrix.os }}
6
-
7
- runs-on: ${{ matrix.os }}
8
- strategy:
9
- matrix:
10
- node: ['14.x']
11
- os: [ubuntu-latest, windows-latest, macOS-latest]
12
-
13
5
  steps:
14
- - name: Checkout repo
15
- uses: actions/checkout@v2
6
+ - uses: actions/checkout@v2
16
-
17
- - name: Use Node ${{ matrix.node }}
18
- uses: actions/setup-node@v1
7
+ - uses: actions/setup-node@v1
19
8
  with:
20
- node-version: ${{ matrix.node }}
9
+ node-version: 14.x
21
-
22
- - name: Install
23
- uses: bahmutov/npm-install@v1
10
+ - uses: bahmutov/npm-install@v1
24
-
25
- - name: Test
26
- run: npm test
11
+ - run: npm test
readme.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # atoms-element
2
2
 
3
3
  [![Version](https://img.shields.io/npm/v/atoms-element?style=flat-square&color=blue)](https://www.npmjs.com/package/atoms-element)
4
+ ![Test](https://github.com/pyros2097/atoms-element/actions/workflows/main.yml/badge.svg)
4
5
 
5
6
  A simple web component library for defining your custom elements. It works on both client and server. It supports hooks and follows the same
6
7
  principles of react. Props are attributes on the custom element by default so its easier to debug.
test/index.test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { expect, test, jest } from '@jest/globals'
2
- import { number, boolean, string, array, object } from '../src/index.js';
2
+ import { html, render, number, boolean, string, array, object } from '../src/index.js';
3
3
 
4
4
  const logMock = jest.fn();
5
5
  window.logError = logMock;
@@ -120,4 +120,19 @@ test('array', () => {
120
120
  expectError(`'items[1].street' Field is required`);
121
121
  array(schema).validate(context, [{ street: '123' }, { street: false }]);
122
122
  expectError(`'items[1].street' Expected type 'string' got type 'boolean'`);
123
- });
123
+ });
124
+
125
+ test('render', async () => {
126
+ const data = { name: '123', address: { street: '1' } }
127
+ const template = html`
128
+ <div>
129
+ <app-counter name="123" details=${data}></app-counter>
130
+ </div>
131
+ `;
132
+ const res = await render(template);
133
+ expect(res).toEqual(`
134
+ <div>
135
+ <app-counter name=\"123\" details=\"{'name':'123','address':{'street':'1'}}\"></app-counter>
136
+ </div>
137
+ `);
138
+ })