mirror of
https://github.com/qntm/base1
synced 2025-12-25 04:54:40 +01:00
Compare commits
2 Commits
403846ebc2
...
3ef962ae42
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ef962ae42 | ||
|
|
9f34801763 |
12
.travis.yml
12
.travis.yml
@ -3,3 +3,15 @@ node_js:
|
||||
- 10
|
||||
- 12
|
||||
- 14
|
||||
cache:
|
||||
directories:
|
||||
# we also need to cache folder with Cypress binary
|
||||
- ~/.cache
|
||||
install:
|
||||
- npm install
|
||||
script:
|
||||
- npx cypress cache path
|
||||
- npx cypress cache list
|
||||
- npm run test
|
||||
- npm run build
|
||||
- npm run test-built
|
||||
|
||||
8
cypress.json
Normal file
8
cypress.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"fixturesFolder": false,
|
||||
"integrationFolder": "test-built",
|
||||
"pluginsFile": false,
|
||||
"screenshotOnRunFailure": false,
|
||||
"supportFile": false,
|
||||
"video": false
|
||||
}
|
||||
14
package.json
14
package.json
@ -23,17 +23,25 @@
|
||||
"jest": "jest",
|
||||
"rollup": "rollup",
|
||||
"standard": "standard",
|
||||
"test": "standard && jest --coverage"
|
||||
"test": "standard && jest --coverage",
|
||||
"test-built": "npm run test-built-cjs && npm run test-built-es6 && npm run test-built-iife",
|
||||
"test-built-cjs": "node test-built/cjs.js",
|
||||
"test-built-es6": "babel-node test-built/es6.js",
|
||||
"test-built-iife": "start-server-and-test \"node test-built/server.js\" http://localhost:3000/test-built/index.html \"cypress run --spec test-built/iife.js\""
|
||||
},
|
||||
"author": "qntm",
|
||||
"license": "MIT",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@babel/node": "^7.10.5",
|
||||
"@babel/preset-env": "^7.7.7",
|
||||
"cypress": "^4.12.1",
|
||||
"express": "^4.17.1",
|
||||
"glob": "^7.1.6",
|
||||
"jest": "^26.4.0",
|
||||
"rollup": "^1.29.0",
|
||||
"standard": "^14.3.1"
|
||||
"rollup": "^2.26.0",
|
||||
"standard": "^14.3.1",
|
||||
"start-server-and-test": "^1.11.3"
|
||||
},
|
||||
"babel": {
|
||||
"presets": [
|
||||
|
||||
8
test-built/cjs.js
Normal file
8
test-built/cjs.js
Normal file
@ -0,0 +1,8 @@
|
||||
const { encode, decode } = require('..')
|
||||
|
||||
const before = [1, 2, 3]
|
||||
const after = Array.from(decode(encode(Uint8Array.from(before))))
|
||||
|
||||
if (JSON.stringify(after) !== JSON.stringify(before)) {
|
||||
throw Error()
|
||||
}
|
||||
10
test-built/es6.js
Normal file
10
test-built/es6.js
Normal file
@ -0,0 +1,10 @@
|
||||
// I want to write '..' here, but I can't figure out a way to get Babel to
|
||||
// follow `package.json`'s "module" property instead of its "main" property
|
||||
import { encode, decode } from '../dist/es6/base1'
|
||||
|
||||
const before = [1, 2, 3]
|
||||
const after = Array.from(decode(encode(Uint8Array.from(before))))
|
||||
|
||||
if (JSON.stringify(after) !== JSON.stringify(before)) {
|
||||
throw Error()
|
||||
}
|
||||
8
test-built/iife.js
Normal file
8
test-built/iife.js
Normal file
@ -0,0 +1,8 @@
|
||||
/* global describe, it, cy */
|
||||
|
||||
describe('base1 IIFE', () => {
|
||||
it('works', () => {
|
||||
cy.visit('http://localhost:3000/test-built/index.html')
|
||||
cy.contains('yo')
|
||||
})
|
||||
})
|
||||
17
test-built/index.html
Normal file
17
test-built/index.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script crossorigin src="../dist/iife/base1.js"></script>
|
||||
<script>
|
||||
window.addEventListener('load', () => {
|
||||
const encoded = base1.encode(new TextEncoder('utf-8').encode('yo'))
|
||||
const decoded = new TextDecoder('utf-8').decode(base1.decode(encoded))
|
||||
document.querySelector('.root').appendChild(document.createTextNode(decoded))
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
6
test-built/server.js
Normal file
6
test-built/server.js
Normal file
@ -0,0 +1,6 @@
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
app.use(express.static('.'))
|
||||
app.listen(3000, () => {
|
||||
console.log('listening')
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user