Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

Commit cf5b667

Browse files
committed
Add tests and other stuff
1 parent 106db08 commit cf5b667

File tree

9 files changed

+1956
-0
lines changed

9 files changed

+1956
-0
lines changed

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"
12+
- package-ecosystem: "github-actions"
13+
directory: "/"
14+
schedule:
15+
interval: "daily"

.github/workflows/npm-publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: 16
18+
- run: npm ci
19+
# Once tests are added, this will be revisited.
20+
# - run: npm test
21+
22+
publish-npm:
23+
needs: build
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: actions/setup-node@v2
28+
with:
29+
node-version: 16
30+
registry-url: https://registry.npmjs.org/
31+
- run: npm ci
32+
- run: tsc -p tsconfig.json
33+
- run: rm arrayStringMap.ts
34+
- run: npm publish
35+
env:
36+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.github/workflows/test.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Tests
2+
'on':
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
10+
jobs:
11+
test:
12+
name: 'Node.js v${{ matrix.node }}'
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node:
17+
- 16
18+
- 17
19+
steps:
20+
- uses: actions/setup-node@v1
21+
with:
22+
node-version: '${{ matrix.node }}'
23+
- uses: actions/checkout@v2
24+
- name: Install Dependencies
25+
run: npm ci
26+
- name: Run All Node.js Tests
27+
run: npm test

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.github
2+
tsconfig.json
3+
objectToWrapper.ts
4+
*.test.*

SECURITY.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
Use this section to tell people about which versions of your project are
6+
currently being supported with security updates.
7+
8+
| Version | Supported |
9+
|---------|--------------------|
10+
| 2.x | :white_check_mark: |
11+
| 1.x. | :x: |
12+
13+
## Reporting a Vulnerability
14+
15+
Please contact me directly at sarkaraoyan@gmail.com.

objectToWrapper.test.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import {assert} from "chai"
2+
import objectToWrapper from "./objectToWrapper.js"
3+
4+
describe("objectToWrapper Test Suite", () => {
5+
it("should return empty wrapper", () => {
6+
const wrapper = objectToWrapper({})
7+
assert.deepEqual(wrapper, {})
8+
})
9+
it("should return wrapper with one property", () => {
10+
const wrapper = objectToWrapper({
11+
foo: "bar"
12+
})
13+
assert.deepEqual(wrapper, {
14+
foo: "bar"
15+
})
16+
})
17+
it("should return wrapper with two properties", () => {
18+
const wrapper = objectToWrapper({
19+
foo: "bar",
20+
bar: "foo"
21+
})
22+
assert.deepEqual(wrapper, {
23+
foo: "bar",
24+
bar: "foo"
25+
})
26+
})
27+
it("should return wrapper with three string properties, no numbers", () => {
28+
const wrapper = objectToWrapper({
29+
foo: 1,
30+
bar: 2,
31+
spam: "eggs"
32+
})
33+
assert.deepEqual(wrapper, {
34+
foo: "1",
35+
bar: "2",
36+
spam: "eggs"
37+
})
38+
})
39+
it("should return wrapper with all string properties", () => {
40+
const wrapper = objectToWrapper({
41+
foo: true,
42+
bar: 3.5,
43+
spam: null,
44+
eggs: "spam"
45+
})
46+
assert.deepEqual(wrapper, {
47+
foo: "true",
48+
bar: "3.5",
49+
spam: "",
50+
eggs: "spam"
51+
})
52+
})
53+
})

0 commit comments

Comments
 (0)