@jseeio/jsee 0.2.1 → 0.2.5

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.
package/test.js ADDED
@@ -0,0 +1,121 @@
1
+ require('expect-puppeteer')
2
+
3
+ page.setDefaultTimeout(1000)
4
+
5
+ const port = 8080
6
+ const urlSchema = (name) => `http://localhost:${port}/load.html?s=/test/${name}.schema.json`
7
+ const urlHTML = (name) => `http://localhost:${port}/test/${name}.html`
8
+ const urlQuery = (schema) => `http://localhost:${port}/load.html?s=${JSON.stringify(schema)}`
9
+
10
+ describe('Initial test', () => {
11
+ beforeAll(async () => {
12
+ await page.goto(urlSchema('sum'))
13
+ })
14
+ test('Title', async () => {
15
+ await expect(page).toMatch('title')
16
+ })
17
+ test('Description', async () => {
18
+ await expect(page).toMatch('description')
19
+ })
20
+ test('Run button is active', async () => {
21
+ await expect(page).toClick('button', { text: 'Run' })
22
+ })
23
+ test('Default result is right', async () => {
24
+ await expect(page).toMatch('142')
25
+ })
26
+ test('Changing inputs', async () => {
27
+ await expect(page).toFill('#a', '200')
28
+ await expect(page).toClick('button', { text: 'Run' })
29
+ await expect(page).toMatch('242')
30
+ // await jestPuppeteer.debug()
31
+ })
32
+ })
33
+
34
+
35
+ describe('Initial test (worker)', () => {
36
+ beforeAll(async () => {
37
+ await page.goto(urlSchema('sumw'))
38
+ })
39
+ test('Result is right', async () => {
40
+ await expect(page).toFill('#a', '8')
41
+ await expect(page).toFill('#b', '7')
42
+ await expect(page).toClick('button', { text: 'Run' })
43
+ await expect(page).toMatch('15')
44
+ })
45
+ })
46
+
47
+ describe('Some edge cases', () => {
48
+ const schema = {
49
+ 'model': {
50
+ 'code': 'function (a, b) { return a / b }', // TODO: check '+'
51
+ }
52
+ }
53
+ test('Minimal', async () => {
54
+ schema.model.worker = false
55
+ await page.goto(urlQuery(schema))
56
+ await expect(page).toFill('#a', '100')
57
+ await expect(page).toFill('#b', '4')
58
+ await expect(page).toClick('button', { text: 'Run' })
59
+ await expect(page).toMatch('25')
60
+ })
61
+ })
62
+
63
+ describe('Load code directly', () => {
64
+ test('Window', async () => {
65
+ await page.goto(urlHTML('code'))
66
+ await expect(page).toFill('#a', '8')
67
+ await expect(page).toFill('#b', '7')
68
+ await expect(page).toClick('button', { text: 'Run' })
69
+ await expect(page).toMatch('15')
70
+ })
71
+ test('Window (string with eval)', async () => {
72
+ await page.goto(urlHTML('string'))
73
+ await expect(page).toFill('#a', '8')
74
+ await expect(page).toFill('#b', '7')
75
+ await expect(page).toClick('button', { text: 'Run' })
76
+ await expect(page).toMatch('15')
77
+ })
78
+ test('Worker', async () => {
79
+ await page.goto(urlHTML('codew'))
80
+ await expect(page).toFill('#a', '8')
81
+ await expect(page).toFill('#b', '7')
82
+ await expect(page).toClick('button', { text: 'Run' })
83
+ await expect(page).toMatch('15')
84
+ })
85
+ test('Worker (string)', async () => {
86
+ await page.goto(urlHTML('stringw'))
87
+ await expect(page).toFill('#a', '8')
88
+ await expect(page).toFill('#b', '7')
89
+ await expect(page).toClick('button', { text: 'Run' })
90
+ await expect(page).toMatch('15')
91
+ })
92
+ })
93
+
94
+ describe('Classes', () => {
95
+ const schema = {
96
+ 'model': {
97
+ 'name': 'Doubler',
98
+ 'method': 'double',
99
+ 'type': 'class',
100
+ 'container': 'args',
101
+ 'url': '/test/example-class.js',
102
+ },
103
+ 'inputs': [
104
+ { 'name': 'b', 'type': 'int', 'default': 100 }
105
+ ]
106
+ }
107
+
108
+ test('Window', async () => {
109
+ schema.model.worker = false
110
+ await page.goto(urlQuery(schema))
111
+ await expect(page).toClick('button', { text: 'Run' })
112
+ await expect(page).toMatch('200')
113
+ })
114
+
115
+ test('Worker', async () => {
116
+ schema.model.worker = true
117
+ await page.goto(urlQuery(schema))
118
+ await expect(page).toClick('button', { text: 'Run' })
119
+ await expect(page).toMatch('200')
120
+ })
121
+ })
package/webpack.config.js CHANGED
@@ -87,7 +87,9 @@ module.exports = (env) => {
87
87
  },
88
88
  }
89
89
  })],
90
- }
90
+ },
91
+ // Source map
92
+ devtool: 'eval'
91
93
  }
92
94
 
93
95
  return config